添加程序集引用后,命名空间中不存在类型或命名空间名称“ComponentModel”

cod*_*ane 3 c# visual-studio-2010

我有一个奇怪的问题,事实证明很难诊断。将包含命名空间的程序集引用添加Matrix.System到 Windows 服务项目后,我现在在编译服务时收到此错误:

命名空间“Matrix.System”中不存在类型或命名空间名称“ComponentModel” 命名空间“Matrix.System”中不存在类型或命名空间名称“ServiceProcess”

但错误是在服务中生成的:

private System.ComponentModel.IContainer components = null;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
Run Code Online (Sandbox Code Playgroud)

在服务设置项目中我得到了这个:

无法找到程序集“Apache.NMS.ActiveMQ.dll”的依赖项“IONIC.ZLIB”(签名=“EDBE51AD942A3F5C”版本=“1.9.1.5”)

NMS 程序集已经在设置项目中,并且一切正常,直到我添加Matrix.System程序集

Jon*_*eet 5

您可以像这样“root”命名空间:

using global::System.ComponentModel;
Run Code Online (Sandbox Code Playgroud)

(然后删除代码中的完全限定引用。)

或者,如果您确实想使用完全限定的命名空间:

private global::System.ComponentModel.IContainer components = null;
private global::System.ServiceProcess.ServiceInstaller serviceInstaller;
Run Code Online (Sandbox Code Playgroud)

但这看起来与其他依赖性问题无关。

我的猜测是,在同一个班级中,您有:

using Matrix;
Run Code Online (Sandbox Code Playgroud)

否则我一开始就不会认为这是一个问题。