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

Gut*_*iro 3 c# dependency-injection unity-container

当我开始我的项目(基于奥尔良项目)时,发现缺少引用引发了一个奇怪的警告:

 [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   
Run Code Online (Sandbox Code Playgroud)

Microsoft.Practices.ServiceLocation 没有出现在 Unity Nuget 包中,我在任何地方都找不到它!这导致我的应用程序出现一些奇怪的运行时行为。

我正在使用 nuget 的最新 Unity。随附的屏幕截图证明了依赖关系 (ILSpy) 以及 VS 上的项目参考 + Nuget 包管理器屏幕。

证据

这个参考真的有必要吗?我怎样才能摆脱它?

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

Jua*_*gui 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>
Run Code Online (Sandbox Code Playgroud)

反正。下面这个应该是你丢失的包裹吧?

https://www.nuget.org/packages/CommonServiceLocator/1.2.0