C# - 引用类型 'ISomeInterface' 在未引用的程序集中定义
C# - The reference type 'ISomeInterface' is defined in an assembly that is not referenced
我负责将我们公司的核心库从 Compact Framework 2.0 迁移到 Visual Studio 2008 年 运行 到 Visual Studio 2015,Update 3 和 .Net 4.6。我创建了新的 class 库并更改了引用以指向旧库的相应 .Net 版本。例如,如果我们有一个引用 Sender.dll 和 Utils.dll 的 ProdoctCore 库,在新的 ProducCoreDotNet 库中,我添加了它对 SenderDotNet.dll 和 UtilsDotNet.dll 的引用。然后我将旧的 Compact Framework 的 class 文件添加到新的解决方案中,方法是将它们添加 "as link"。所以基本上项目名称具有 DotNet 扩展名,但命名空间具有与之前完全相同的名称。
现在我面临的问题是出现了一个奇怪的错误:
"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'"
但是,我的 UtilsDotNet 的版本是 1.0.0.0,旧的 Utils 是 2.0.0.0 版本。
我在 SO 上阅读了几个类似的线程,但与 this question 中提到的不同,IMonitorComponent 没有对其他程序集的任何引用。它只是一个具有几个属性的接口:
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; }
}
所以我没有想法,非常感谢你的帮助。另外,请详细说明你的答案,因为我以前没有做过这样的事情。
终于找到原因了。我们使用的是另一个使用 Utils 1.5 版的参考。因此,我为该参考创建了另一个 class 库,并使用新的 UtilsDotNet 作为参考,问题得到解决。
我负责将我们公司的核心库从 Compact Framework 2.0 迁移到 Visual Studio 2008 年 运行 到 Visual Studio 2015,Update 3 和 .Net 4.6。我创建了新的 class 库并更改了引用以指向旧库的相应 .Net 版本。例如,如果我们有一个引用 Sender.dll 和 Utils.dll 的 ProdoctCore 库,在新的 ProducCoreDotNet 库中,我添加了它对 SenderDotNet.dll 和 UtilsDotNet.dll 的引用。然后我将旧的 Compact Framework 的 class 文件添加到新的解决方案中,方法是将它们添加 "as link"。所以基本上项目名称具有 DotNet 扩展名,但命名空间具有与之前完全相同的名称。
现在我面临的问题是出现了一个奇怪的错误:
"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'"
但是,我的 UtilsDotNet 的版本是 1.0.0.0,旧的 Utils 是 2.0.0.0 版本。
我在 SO 上阅读了几个类似的线程,但与 this question 中提到的不同,IMonitorComponent 没有对其他程序集的任何引用。它只是一个具有几个属性的接口:
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; }
}
所以我没有想法,非常感谢你的帮助。另外,请详细说明你的答案,因为我以前没有做过这样的事情。
终于找到原因了。我们使用的是另一个使用 Utils 1.5 版的参考。因此,我为该参考创建了另一个 class 库,并使用新的 UtilsDotNet 作为参考,问题得到解决。