The type 'InversionOfControl.IOC' exists in both 'InversionOfControl.dll' and 'InversionOfControl.dll'

雨燕双飞 提交于 2020-01-07 03:58:28

问题


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:

Value cannot be null.
Parameter name: container

on normal resolves:

ITransmitModel transmitModel = IOC.Container.Resolve<ITransmitModel>();

When I try to inspect IOC.Container, the value in the watch window is:

The type 'InversionOfControl.IOC' exists in both 'InversionOfControl.dll' and '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.)

Why does it think there are two dlls called InversionOfControl.dll?


回答1:


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.

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").



来源:https://stackoverflow.com/questions/9743782/the-type-inversionofcontrol-ioc-exists-in-both-inversionofcontrol-dll-and-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!