question

PeterCliftINFOSYSLIMITED-1210 avatar image
0 Votes"
PeterCliftINFOSYSLIMITED-1210 asked PeterCliftINFOSYSLIMITED-1210 commented

how to fix : Could not load file or assembly 'Azure.Core'

I have a .net framework 4.2 Test Project, which calls methods in .net 4.2 a class library called Interface. Interface references another class library that holds the nuget 'azure.core'

in the test project , I tried adding a bindingRedirect to app.config , but did not fix :

       <dependentAssembly>
         <assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral" />
         <bindingRedirect oldVersion="0.0.0.0-1.25.0.0" newVersion="1.25.0.0" />
       </dependentAssembly>



here is the error :
Exeption message "Could not load file or assembly 'Azure.Core, Version=1.25.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Azure.Core, Version=1.25.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8"} System.Exception {System.IO.FileLoadException}

inner exception : - InnerException {"Could not load file or assembly 'Azure.Core, Version=1.19.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Azure.Core, Version=1.19.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8"} System.Exception {System.IO.FileLoadException}


Any tips?
Thanks,Peter


dotnet-package-management
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @PeterCliftINFOSYSLIMITED-1210 ,

Welcome to Microsoft Q&A forum. Can you confirm that the Azure.Core NuGet package version 1.25.0.0 is installed(exists) locally? And, have you tried to change the version to 1.19.0.0 in bindingRedirect? Like <bindingRedirect oldVersion="0.0.0.0-1.19.0.0" newVersion="1.19.0.0" />? Besides, did you miss this line <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> in app.config file?

0 Votes 0 ·

hi, TianyuSun,

Azure.core dll is installed - see picture below.

My understanding is that my binding redirect is for a range , so it should have fixed the 1.19.0.0 version. Right?



238233-az-core.png


0 Votes 0 ·
az-core.png (3.7 KiB)
TianyuSun-MSFT avatar image TianyuSun-MSFT PeterCliftINFOSYSLIMITED-1210 ·

Hi Peter,

Yes. So does cleaning NuGet package cache then restoring NuGet packages, and rebuilding your project work?

0 Votes 0 ·

hi TianyuSun,

I don't understand why cleaning NuGet package cache would help. I have a similar project which works fine on my dev machine.

0 Votes 0 ·
TianyuSun-MSFT avatar image TianyuSun-MSFT PeterCliftINFOSYSLIMITED-1210 ·

Hi Peter,

Sometimes, the modifications are set but the cache(nuget cache and project cache) doesn’t change at once, this may lead to this issue. So cleaning the cache or reinstalling the package and rebuilding the project may work.

0 Votes 0 ·

can anyone else help me?

maybe a dependent assembly is missing a redirect -how do I find it?

0 Votes 0 ·

1 Answer

PeterCliftINFOSYSLIMITED-1210 avatar image
0 Votes"
PeterCliftINFOSYSLIMITED-1210 answered TianyuSun-MSFT commented

I answered my question. I added this to csproj of calling test project :

 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
 <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Peter,

Thanks for sharing your solution here, and I’m happy to hear that this issue doesn’t block you any more.

Have a nice day.

Regards,
Tianyu

0 Votes 0 ·