简体   繁体   English

NuGet包GAC依赖

[英]NuGet package GAC dependency

When running my .NET project I get the following run-time error: 运行我的.NET项目时,我收到以下运行时错误:

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. 据我所知, Microsoft.WindowsAzure.ServiceRuntime是一个GAC依赖项,在NuGet上不可用。

My .NET project is referencing 2.5.0.0 of ServiceRuntime from the Azure SDK 2.5. 我的.NET项目从Azure SDK 2.5引用了2.5.0.0的ServiceRuntime。 The stacktrace of the exception reveals that one of our custom NuGet packages references 2.4.0.0. 异常的堆栈跟踪显示我们的一个自定义NuGet包引用了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包的依赖关系时,它没有显示ServiceRuntime,我认为这是因为它是GAC引用(NuGet无法解析的东西):

NuGet Depedencies

I found that by adding the following web.config change, it now works: 我发现通过添加以下web.config更改,它现在可以工作:

<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. 我认为这仅在2.5.0.0向后兼容2.4.0.0规范时才有效。

Questions: 问题:

  • What would happen if it was not backwards compatible? 如果它不向后兼容会发生什么?
  • Why isn't Microsoft.WindowsAzure.ServiceRuntime a NuGet package? 为什么Microsoft.WindowsAzure.ServiceRuntime不是NuGet包?

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. 你的解决方案会破坏,虽然下一个版本的程序集不是向后兼容的极不可能,你可以使用更新版本的.Net / CLR运行任何旧的.net程序,最近它会显示弃用消息,它只会在漂亮之后很长一段时间它不会立即停止支持,就像这种情况一样。 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? 为什么Microsoft.WindowsAzure.ServiceRuntime不是NuGet包?

First understand the reason for the existence of the Nuget here , in essence it is only meant for the 3rd party libraries / extensions. 首先了解了的NuGet的存在的理由在这里 ,它在本质上只是针对第三方库/扩展。 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. 它不适用于核心MS / .Net框架库,其源代码不可用且无法由外部开发人员修改。

Hope this helps to an extent. 希望这在一定程度上有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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