System.Badimageformatexception: Reference Assemblies Should Not Be Loaded for Execution

.Net 4.6 website not loading Reference Assemblies correctly

Resolution:

My library projects were referencing some core libs (System.* etc) with the RequiredTargetFramework option set to 3.5. This was only evident in the csproj file, example:

<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>

Thus causing all sorts of issues with .net versions, visual studio was trying to sort it by adding binding redirects into my web.config to point these to v4 (and include reference assemblies), unsuccessfully.

Removing all RequiredTargetFramework elements from the csproj files has solved the problem.

.NET Core vs .NET Framework - Could not load file or assembly 'System.ServiceModel, Reference assemblies should not be loaded for execution

Actually, it turned out to be quite simple!

I had to add a reference to System.ServiceModel.Primitives nuget in the .NET core application and it started to work all ok!



Related Topics



Leave a reply



Submit