当运行我的.NET项目中,我得到以下运行时错误:NuGet包GAC依赖
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.
从我个人理解,Microsoft.WindowsAzure.ServiceRuntime
是GAC依赖和不提供的NuGet。
我的.NET项目引用了Azure SDK 2.5中ServiceRuntime的2.5.0.0。异常的堆栈跟踪显示我们的一个自定义NuGet包引用了2.4.0.0。
当在NuGet包的依赖关系来看,它并不显示ServiceRuntime,我以为是因为它是一个GAC引用(东西它的NuGet无法解析):
我发现,通过加入以下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>
我会认为这只是工作,如果2.5.0.0与2.4.0.0规范向后兼容。
问题:如果它是不向后兼容
- 会发生什么?
- 为什么不是
Microsoft.WindowsAzure.ServiceRuntime
的NuGet包?
Nuget绝对不只适用于第三方库。微软甚至在nuget上有自己的feed - https://www.nuget.org/profiles/microsoft - 目前包含超过1100个软件包。 – 2014-12-22 10:32:15
MS不通过Nuget提供核心.Net库,链接中提到的库是用于附加功能的可选库,在许多情况下,它们具有第三方竞争对手或者可以覆盖,以修改当前的实现 – 2014-12-22 10:37:24
在我提到的链接,你会看到很多可以被认为是核心的库。 - 例如MVC,WebApi,OData,Razor,Owin和EntityFramework。但是你确定对于某些事情是正确的,我们不幸的是仍然需要安装SDK的++ – 2014-12-23 12:58:23