C# 类型或命名空间名称';组件模型&x27;添加程序集引用后命名空间中不存在

C# 类型或命名空间名称';组件模型&x27;添加程序集引用后命名空间中不存在,c#,visual-studio-2010,C#,Visual Studio 2010,我有一个奇怪的问题,很难诊断。将包含命名空间Matrix.System的程序集引用添加到Windows服务项目后,我现在在编译服务时遇到以下错误: 中不存在类型或命名空间名称“ComponentModel” 命名空间“Matrix.System”类型或命名空间名称“ServiceProcess” 命名空间“Matrix.System”中不存在 这些错误是在服务中生成的,尽管: private System.ComponentModel.IContainer components = null;

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

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

这些错误是在服务中生成的,尽管:

private System.ComponentModel.IContainer components = null;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
在服务设置项目中,我得到以下信息:

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

NMS程序集已经在安装项目中,在我添加
矩阵之前,一切正常。System
assembly

您可以像这样“根目录”名称空间:

using global::System.ComponentModel;
(然后去掉代码中的完全限定引用。)

或者,如果您确实希望使用完全限定的名称空间:

private global::System.ComponentModel.IContainer components = null;
private global::System.ServiceProcess.ServiceInstaller serviceInstaller;
不过,这看起来与其他依赖性问题无关

我猜你在同一个班上:

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

您可以像这样“根目录”名称空间:

using global::System.ComponentModel;
(然后去掉代码中的完全限定引用。)

或者,如果您确实希望使用完全限定的名称空间:

private global::System.ComponentModel.IContainer components = null;
private global::System.ServiceProcess.ServiceInstaller serviceInstaller;
不过,这看起来与其他依赖性问题无关

我猜你在同一个班上:

using Matrix;

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

您需要从Nuget admin软件包安装
system.componentmodel
。 因为Microsoft参考或系统中都没有
system.componentmodel
。 请注意,framework 2.0不支持它,至少需要.Net framework 4.3


您需要从Nuget管理软件包安装
system.componentmodel
。 因为Microsoft参考或系统中都没有
system.componentmodel
。 请注意,framework 2.0不支持它,至少需要.Net framework 4.3


谢谢你。阅读您的答案让我意识到Matrix.System在某种程度上“屏蔽”了系统名称空间。将矩阵系统更改为其他系统并重新导入解决了问题。很多人为此感谢你。阅读您的答案让我意识到Matrix.System在某种程度上“屏蔽”了系统名称空间。将矩阵系统更改为其他系统并重新导入解决了问题。非常感谢