c# - 添加程序集引用后,类型或命名空间名称 'ComponentModel' 在命名空间中不存在

标签 c# visual-studio-2010

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

The type or namespace name 'ComponentModel' does not exist in the namespace 'Matrix.System' The type or namespace name 'ServiceProcess' does not exist in the namespace 'Matrix.System'

错误是在服务中生成的:

private System.ComponentModel.IContainer components = null;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;

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

Unable to find dependency 'IONIC.ZLIB' (Signature='EDBE51AD942A3F5C' Version='1.9.1.5') of assembly 'Apache.NMS.ActiveMQ.dll'

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

最佳答案

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

using global::System.ComponentModel;

(然后去掉代码中的完全限定引用。)

或者如果您真的想要使用完全限定的命名空间:

private global::System.ComponentModel.IContainer components = null;
private global::System.ServiceProcess.ServiceInstaller serviceInstaller;

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

我猜你在同一个类(class):

using Matrix;

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

关于c# - 添加程序集引用后,类型或命名空间名称 'ComponentModel' 在命名空间中不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11373553/

相关文章:

asp.net - 如何在Windows Azure云服务中读取Excel文件中的数据?

asp.net - Visual Studio 2010 - 部分发布网站?

c# - 将 Visual Studio 项目添加到 AOT

jquery - 用于测试和调试 HTML5 手机游戏的开发平台/模拟器

c# - 如何在 C# 中的 ContinueWith 之前使用延迟来执行 Task.ContineWith?

c# - 如何以编程方式更新嵌入式 SQL 连接的命令属性

c# - 如何使用 NetTopologySuite 以米为单位获取两点几何的距离?

visual-studio-2010 - Visual Studio 2010 宏问题 - 一起退出工作

c# - 并行执行多对并发任务

c# - 您建议编写哪些教学玩具程序来理解证书?