Reputation: 1741
I'm running a .Net Standard project that uses the nuget package Microsoft.Extensions.Caching.Memory
, and it's called from a .Net Framework ASP.Net Web project. When the code referencing this nuget package is run, I get the following error:
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Extensions.Caching.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.'
I've tried adding Microsoft.Extensions.Caching.Abstractions
nuget package to my .Net Standard project but it didn't help. I've also tried adding the following to my .Net Framework project but it didn't help either:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
Does anyone have a workaround to this problem? There are no other projects referencing Microsoft.Extensions.Caching.Abstractions
so I don't know why it can't find it with the correct version.
Upvotes: 1
Views: 3633
Reputation: 152
Add the same package, Microsoft.Extensions.Caching.Memory
, to your .NET Framework project.
This causes it to build using the .NET Framework targeting as with the previous answer, but without polluting your .NET Standard project or requiring it to know which version of .NET Framework it needs to support.
Upvotes: 1
Reputation: 1741
I was able to solve this .Net Standard dll hell by adding other framework bindings. The .Net Framework version I was calling the .Net Standard project was all 4.6.2 which I could not upgrade, moving up to 4.7.* may also have addressed it but I didn't try it as it wasn't viable in my case. All other solutions presented above did not work, and the .dll's for the nuget packages could not be loaded for some reason.
In my .Net Standard project I changed:
<TargetFramework>netstandard2.0</TargetFramework>
to:
<TargetFrameworks>netstandard2.0;net462;net47</TargetFrameworks>
This of course will compile your project against all frameworks you need to build against.
Upvotes: 0