问题描述
我有一个名为 InversionOfControl
的项目.该项目有一个名为 IOC
的类.它看起来像这样:
I have a project called InversionOfControl
. That project has a class called IOC
. It looks like this:
/// <summary>
/// This class is used to expose the unity container to the application.
/// </summary>
public class IOC
{
/// <summary>
/// The actual unity container for the app.
/// </summary>
public static IUnityContainer Container { get; set; }
}
我所有需要解决统一注入的项目都有对这个类的引用.最近我开始收到这个错误:
All my projects that need to resolve unity injections have a reference to this class. Lately I have started getting this error:
值不能为空.
参数名称:容器
正常解析:
ITransmitModel transmitModel = IOC.Container.Resolve<ITransmitModel>();
当我尝试检查 IOC.Container
时,观察窗口中的值为:
When I try to inspect IOC.Container
, the value in the watch window is:
类型InversionOfControl.IOC"存在于InversionOfControl.dll"和InversionOfControl.dll"中
我查看了我的输出文件夹,发现只有一个 InversionOfControl.dll 文件.(我什至清理了我的解决方案并仔细检查了文件夹是否为空.然后我重建并再次检查只有一个.)
I have looked in my output folder and there is only one InversionOfControl.dll file. (I even cleaned my solution and double checked the folder was empty. I then rebuilt and checked again that there is only one.)
为什么它认为有两个名为 InversionOfControl.dll 的 dll?
Why does it think there are two dlls called InversionOfControl.dll?
推荐答案
一种检查运行时加载的模块的方法是Debug->Windows->Modules"并检查有问题的 DLL 是从哪里加载的.确保您没有加载 2 个不同版本的程序集.
A way to check what module is loaded at run-time is "Debug->Windows->Modules" and check out where the DLL in question is loaded from. Make sure you are not loading 2 assemblies with different versions.
作为下一步,我将搜索具有此名称的所有文件,以查看是否存在可疑副本(cd/d c:\ & dir/s/b InversionOfControl.dll").
As a next step I would do search for all files with this name to see if there are suspicious copies ("cd /d c:\ & dir /s /b InversionOfControl.dll").
这篇关于类型“InversionOfControl.IOC"存在于“InversionOfControl.dll"和“InversionOfControl.dll"中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!