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

标签 c# dependency-injection unity-container

当我开始我的项目(基于 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 包中,我在任何地方都找不到它!这导致我的应用程序出现一些奇怪的运行时行为。

我正在使用来自 nuget 的最新 Unity。附件是一些屏幕截图,证明了依赖关系 (ILSpy) 和项目引用 + VS 上的 Nuget 包管理器屏幕。

Evidences

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

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

最佳答案

尝试获取较新的版本,然后重定向到该特定版本。

<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

关于c# - Unity 无法加载文件或程序集 'Microsoft.Practices.ServiceLocation,版本 = 1.2.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31641643/

相关文章:

c# - 从 ViewModel 中的绑定(bind)更新 DataGrid 背景

c# - 具有默认 0(零)值的属性索引器

javafx - 传递参数JavaFX FXML

c# - 这是使用基于约定的方法在 Unity 中注册类型的正确方法吗?

c# - Unity、Moq 和 NUnit - Controller 构造函数的参数在测试中无法识别

c# - 如果以本地管理员身份运行,如何 checkin C#

c# - 在 Web 应用程序内部调试控制台应用程序

java - 跨多线程的 Spring bean 引用

c# - 如何在 dotnet core 3 中使用依赖项在启动时调用自定义服务?

c# - PostSharp 中的依赖注入(inject)