我遇到了一个难以诊断的奇怪问题。将包含命名空间 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/