System.PlatformNotSupportedException: 'Windows Principal functionality is not supported on this platform.' #1279
Comments
This should work just fine in .NET Framework. We throw PNSE on Linux, but we do have implementation for Windows. In .NET Framework specifically, our System.Security.Pincipal.WIndows dll should just type forward to mscorlib and use the implementation that comes inbox for this. Can you share more info about how is it that you are referencing WindowsIdentity? Also, if you are targetting .NET Framework, why are you adding a reference to the System.Security.Principal.Windows package? You shouldn't need that since the types you would need live in mscorlib. |
Hello joperezr, If the same API is accessing from .net core application it is working fine. please have a look into the attachment. |
Is the problem that you are seeing happening in ConsoleApp1 of the attached? If so, I did notice that in that project you are missing a property that is required when referencing sdk-style projects from a .NET Framework app. Try setting the following in your ConsoleApp1.csproj: <PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup> After that, run |
Did you manage to get this working? We are seeing the exact same issue where we have a dotnet standard dll that calls
This is using .net framework 4.7.2 referencing a .net standard 2.0 common library. The PackageReference suggestion above sadly did not have any effect on this. |
Having this exact issue as well and workaround didn't solve it. I'm on Windows btw. |
We managed to resolve this issue by marking the common library project as dual-target:
|
I am getting this error when trying to debug a asp.net core 3.1 application with log4net in WSL2 |
I am also having the same issue. |
@MyoMinLin |
Is the bottom line that Docker containers running dotnetcoreapp3.1 are not allowed to call anything with |
@brandonros If you're using Windows on Docker then I'd expect it to work. If you're using any other OS, I'd expect it to fail. Linux doesn't have a notion of a WindowsIdentity. |
Yes this WindowsIdentity Api seems to be specific to windows . |
I can't repro this. Please let us know if this is not working. |
Hello Team,
we are using .net standard libraries in .net framework application. trying to access network share by using Impersonation but windows identity is throwing not supported exception.
Code snippet:
public void RunImpersonated(Action action)
{
using (WindowsIdentity identity = new WindowsIdentity(_token))
{
WindowsIdentity.RunImpersonated(identity.AccessToken, action);
//_context = identity.Impersonate();
}
}
.net standard dll versions:
.net standard -version 2.0
System.Security.Principal.Windows - version: 4.1.1.1
.net framework version -4.7.2
any support to resolve this issue?
The text was updated successfully, but these errors were encountered: