简体   繁体   中英

C# - The reference type 'ISomeInterface' is defined in an assembly that is not referenced

I am in charge of migrating our companies core libraries from Compact Framework 2.0 that used to run on Visual Studio 2008 to Visual Studio 2015, Update 3 and .Net 4.6. I have created new class libraries and have changed the references to point to the corresponding .Net version of the older libraries. For example, if we had a ProdoctCore library that was referencing Sender.dll and Utils.dll, in the new ProducCoreDotNet library, I have added its references to SenderDotNet.dll and UtilsDotNet.dll. Then I have added the class files of the old Compact Framework to the new solution by adding them "as link". So basically the project names have the extention DotNet but the namespaces have exactly the same name is before.

Now the problem that I'm facing is that I'm getting a strange error:

"The reference type 'IMonitorComponent' is defined in an assembly that is not referenced. You must add a reference to assembly 'Utils, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null'"

However, my UtilsDotNet's version is 1.0.0.0 and the old Utils was version 2.0.0.0.

I've read couple of similar threads at SO but unlike what was mentioned in this question , the IMonitorComponent doesn't have any reference to other assemblies. It's simply an interfaces with couple of properties:

 public enum COMPONENT_STATUS
{
    ERROR,
    WARNING,
    OK,
    UNKNOWN,
    DISABLED
}

public class ComponentStatusProperty
{
    public ComponentStatusProperty(string name, COMPONENT_STATUS status, string message)
    {
        ComponentName = name;
        Status = status;
        Message = message;
    }

    public COMPONENT_STATUS Status { get; set; }
    public string Message { get; set; }
    public string ComponentName { get; set; }
}

public interface IMonitorComponent
{
    string Name { get; }
    List<ComponentStatusProperty> Statuses { get; }
    bool ComponentSoBrokenThatTheDeviceCannotWork { get; }
}

So I'm out of ideas and would appreciate your help. Also, please elaborate on you answers as I haven't done anything like this before.

We finally found the reason. We were using another reference that was using the Utils version 1.5. So I created another class library for that reference and used the new UtilsDotNet as its reference and problem was fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM