Unity无法加载文件或程序集'Microsoft.Practices.ServiceLocation,版本=1.2.0.0'。

3

当我开始我的项目(基于Project Orleans),却因为缺少引用而引发了一个奇怪的警告:

 [2015-07-26 20:03:06.970 GMT 6 INFO 100000 AssemblyLoader.Client ] User assembly ignored: C:\Users\Gutemberg\Documents\Visual Studio 2015\Projects\PI - Switch (MS)\PI.Switch.Gateway.Host\bin\Debug\Microsoft.Practices.Unity.dll
* An assembly dependency [Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] could not be loaded: 0   

Microsoft.Practices.ServiceLocation在Unity Nuget包中不存在,我无法找到它的任何信息!这导致我的应用程序出现了一些奇怪的运行时行为。

我使用的是最新的Unity Nuget。以下是一些截图,证明依赖项(ILSpy)以及VS中的项目引用+ Nuget软件包管理器屏幕。

Evidences

这个引用真的必要吗?如何摆脱它?

谢谢!非常感谢您的帮助。


我遇到了这个问题。看一下这个答案!! - KnowGe
1个回答

5
尝试获取更新版本,然后重定向到该特定版本。
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
    </dependentAssembly>
</assemblyBinding>

以下应该是您缺少的包,对吧? https://www.nuget.org/packages/CommonServiceLocator/1.2.0

谢谢回复。问题是,如果这是Unity的依赖项,为什么它没有随Unity一起安装? - Gutemberg Ribeiro
正如您在最后一张截图中看到的依赖项,它只依赖于Windows Store应用程序和MonoDroid。我使用的是完整的.Net 4.5... - Gutemberg Ribeiro

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接