I'm working on an ASP application written in .Net Framework 4.8, running on IIS on Windows Server 2012 R2. I've created a NuGet package, which is a .Net Standard 2.0 library and it all runs happily on my local machine through Visual Studio debugging.
Having deployed it to the server (replaced the existing bin folder with the new one, including all the new files) I am now getting this error.
Could not load file or assembly 'System.Security.Principal.Windows, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I'm running the most up to date version of the MS Build Tools, the latest Windows updates available for the server, and both the .Net Framework application and the .Net Standard library are using version 5 of System.Security.Principal.Windows, despite what this error message says.
I have ensured that all the Windows features related to IIS are enabled on the server as they are on my development machine. I have rebuilt both the application and the library. I have totally uninstalled and reinstalled the System.Security.Principal.Windows NuGet package from both. I have tried setting this in the csproj file for the application:
I have tried setting this in the csproj too:
<PropertyGroup> <!--- ... --> <RestoreProjectStyle>PackageReference</RestoreProjectStyle> <!--- ... --> </PropertyGroup>
So far nothing has worked. I'm unclear on why this is even an issue, given it has worked flawlessly on my local machine.
Any suggestions? The solutions given for other similar issues on Stack Overflow have not worked for me.
The solution to this was to install a NuGet package on both the application project and the library project, specifically
Microsoft.Net.Compilers, which serves to cause the project to be built using the C# and Visual Basic compilers contained in the package, as opposed to the version installed with MSBuild.
While this package is now deprecated, it was the correct version to use given the application is running using .Net Framework, not .Net Core 2.1+.
User contributions licensed under CC BY-SA 3.0