Could Not Load File or Assembly Error in .Net Standard 2.0 Class Library

.Net Standard 2.0 with .Net Framework 4.8 - Could not load file or assembly System.Security.Principal.Windows, Version=4.1.1.0

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+.

.NET Standard + .NET Framework: could not load file or assembly 'Ninject'

Found the solution!

You have to migrate Your packages.config into Your .csproj file.

for more details lookup here.

Nuget - " Could not load file or assembly '{Class Name}, Version= x.x.x., Culture=neutral, PublicKeyToken=null' or one of its dependency"

I don't believe this is an issue with .Net Standard, as I was able to get it loaded, but got a different error, as I have a more recent version of Chrome running, but I was able to load the assemblies fine using Class Lib (.Net Standard 2.0.3) and Console App (.Net Core 3.1).

Screen shot of test project

EDIT: Your output/bin folder should look something like the following:

Sample Image

... and your .csproj file for your reference lib should have at least the follow:
Sample Image

Edit #2: I just noticed from your nuget packages screenshot above that you have warnings on them. Please delete remove you references and try adding them back, or if you right click your project is VS there should be an option to redownload your packages, but I never have much success with the ladder method. However it does seem to be an issue with you packages. If these don't work for you, please try removing your bin and obj folders and rebuild, sometimes this can help. If you still have issues, please share the ⚠️ messages as they might assist in debugging.

Edit #3: You may also want to try and see if adding this <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> to you .csproj file as explained here might help: Nuget Pkg Dlls Missing from Build Folder in .Net Standard DLL Project. dlls are Not Copy Local? Fix in Visual Studio 2019?



Related Topics



Leave a reply



Submit