Sustainsys / Saml2

Saml2 Authentication services for ASP.NET
Other
959 stars 602 forks source link

Support .NET 6 #1329

Closed Wael3bbas closed 2 years ago

Wael3bbas commented 2 years ago

Fix Unable to cast object of type 'System.Security.Cryptography.RSACng' to type 'System.Security.Cryptography.RSACryptoServiceProvider "Sustainsys.Saml2" for .NET 6.0

AndersAbel commented 2 years ago

Did you also change the project file to target .NET 5 or 6 when bulding to require this? If the build target is .Net Standard 2.0, this shouldn't be required as far as I now?

Wael3bbas commented 2 years ago

My project is currently targeting net6.0as below image and what I understand from this Microsoft doc that net5.0 replaces both netcoreappand netstandardTFMs

image

AndersAbel commented 2 years ago

Yes, that's correct. But if you build the library with the netstandard2.0 moniker this shouldn't be needed.

What I'm trying to understand here is if this change is needed for a published nuget to be able to work with .NET 6 projects.

Wael3bbas commented 2 years ago

In my case when I used the latest NuGet v2.8.0 it throw mentioned error and after downloading the code and doing this change it works fine with me.

I think it will be needed for both .NET 5 and 6 as #if NETSTANDARD2_0 will always return false.

AndersAbel commented 2 years ago

Ok, then this is not needed. v2.8.0 does not properly check for .NET5/6. v2.9.0 was just pushed to Nuget, it works with .NET 5 and 6.