简体   繁体   中英

NuGet package GAC dependency

When running my .NET project I get the following run-time error:

Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

From what I understand, Microsoft.WindowsAzure.ServiceRuntime is a GAC dependency and not available on NuGet.

My .NET project is referencing 2.5.0.0 of ServiceRuntime from the Azure SDK 2.5. The stacktrace of the exception reveals that one of our custom NuGet packages references 2.4.0.0.

When looking at the NuGet package's dependencies, it doesn't show ServiceRuntime, which I assume is because it is a GAC reference (something which NuGet cannot resolve):

NuGet Depedencies

I found that by adding the following web.config change, it now works:

<dependentAssembly>
    <assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
</dependentAssembly>

I would assume that this only works if 2.5.0.0 is backwards compatible with the 2.4.0.0 specification.

Questions:

  • What would happen if it was not backwards compatible?
  • Why isn't Microsoft.WindowsAzure.ServiceRuntime a NuGet package?

Though it might be little late to answer the question, nonetheless better late than never. Following is my view:

What would happen if it was not backwards compatible?

You solution would break, though its highly unlikely that the next version of an assembly is not backward compatible, you can run any of old .net program with newer versions of .Net / CLR, atmost it would show deprecation message and its only after pretty long time it will stop supporting not immediately as in this case. An assembly is the next version only if it is backward compatible, else it is a new assembly.

Why isn't Microsoft.WindowsAzure.ServiceRuntime a NuGet package?

First understand the reason for the existence of the Nuget here , in essence it is only meant for the 3rd party libraries / extensions. It is not meant for the core MS / .Net framework libraries, whose source code isn't available and cannot be modified by an outside developer.

Hope this helps to an extent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM