0

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.

Community
  • 1
  • 1
Alir Kahi
  • 1,264
  • 2
  • 15
  • 27
  • I notice that the error is suggesting you add a reference to "Utils" rather than "UtilsDotNet". Could your new project be referencing an old DLL (i.e. via Add Reference -> Browse rather than via Add Reference -> Project)? – wablab Feb 17 '17 at 17:39
  • @wablab I have added all the references as add reference -> Browse by going to the bin/Debug folder of each DotNet version of the assemblies and have added them. Note that the namespace of the Utils and UtilsDotNet are all the same. Also, I only get this error message about this particular interface despite having many referenced assemblies in the same manner. – Alir Kahi Feb 17 '17 at 17:45
  • Assuming ProductCoreDotNet, SenderDotNet, and UtilsDotNet are all in the same VS solution, I would try deleting all references within the solution, and then re-adding them via Add Reference -> Project. Then Rebuild All. – wablab Feb 17 '17 at 17:49
  • 1
    I assume one of your referenced assemblies or nested references uses SpecificVersion (http://stackoverflow.com/questions/24022134/how-exactly-does-the-specific-version-property-of-an-assembly-reference-work-i) and that specific version of the assembly (1.5) is not found. If you do not need the versioning, I would change all references to not use SpecificVersion. – josef Feb 18 '17 at 06:25
  • You need to fix your `.csproj` files, and the simplest way to locate the problem and fix it is to [review the files manually](http://stackoverflow.com/a/35991676/181087) to find the reference or references that are in conflict. – NightOwl888 Feb 18 '17 at 20:46

1 Answers1

1

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.

Alir Kahi
  • 1,264
  • 2
  • 15
  • 27