I am using Visual Studio 2017 and am trying to create a .Net Standard 1.5 library and use it in a .Net 4.6.2 nUnit test project.
I am getting the following error...
it is too late I know, howewer there is no succesfully answer. I found the answer from another website. I fixed the issue when I delete the System.Runtime assemblydependency. I deleted this.
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0"/>
</dependentAssembly>
Best Regards
I fixed it by deleting my app.config
with
<assemblyIdentity name="System.Runtime" ....>
entries.
app.config
was automatically added (but not needed) during refactoring
We have found that AutoGenerateBindingRedirects
might be causing this issue.
Observed: the same project targeting net45
and netstandard1.5
was successfully built on one machine and failed to build on the other. Machines had different versions of the framework installed (4.6.1 - success and 4.7.1 - failure). After upgrading framework on the first machine to 4.7.1 the build also failed.
Error Message:
System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
----> System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Auto binding redirects
is a feature of .net 4.5.1
. Whenever nuget detects that the project is transitively referencing different versions of the same assembly it will automatically generate the config file in the output directory redirecting all the versions to the highest required version.
In our case it was rebinding all versions of System.Runtime
to Version=4.1.0.0
. .net 4.7.1
ships with a 4.3.0.0
version of runtime. So redirect binding was mapping to a version that was not available in a contemporary version of framework.
The problem was fixed with disabling auto binding redirects for 4.5 target and leaving it for .net core only.
<PropertyGroup Condition="'$(TargetFramework)' == 'net45'">
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
Trust me, I am not joking. Remove all the System.Runtime dependencies from your app.config and it will start working.
I had the same problem and no suggested solutions that I found worked. My solution for this issue was: Check App.config and packages.config to see if the versions match.
Originally my app.config contained:
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>
But the packages.config contained:
<package id="System.Runtime" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
I modified the app.config entry to match packages.config for the newVersion:
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.3.0" />
</dependentAssembly>
After the change, the issue was resolved.
I had this error occur when building an Azure Function (with a queue trigger, should it make a difference)
The issue in this case was because the AzureFunctionsVersion
was set to v2 instead of v3. To update it via VS2019, unload the project then edit the csproj file. Within the PropertyGroup
node, add/edit the following:
<PropertyGroup>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>