I tried to update my project to .NET Standard 2.0 and during testing I got catch an exception:
System.IO.FileLoadException: \'Could not load file or a
I've been wrestling with something similar - dll's in the bin folder of webapi2 sln after build. I've deleted a list of dll's and refreshed each time - the error moves on to a different dll. Finally, after deleting 8 dll's the site fires up correctly. My next step is to write a post-build script to delete these dll's from the bin folder. A bit of a hack but the elegant solution can come later.
in my case after update dotnet framework from 4.6 to 4.7 problem solved
I solved this problem by enabling Automatic Binding Redirection in my .NET Framework 4.7 project (that references .NET Standard 2.0 library). Binding redirection can be enabled by manually editing project's .csproj
file and addind following snippet a child of Project
element:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
Visual Studio then during build generates neccessary assembly redirections to project's app.config
, similar to this:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ffffd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
</assemblyBinding>
allowing correct assembly to be loaded.