The type or namespace name 'ComponentModel' does not exist in the namespace after adding an assembly reference

烈酒焚心 提交于 2020-01-05 04:34:09

问题


I have a strange problem that's proving difficult to diagnose. After adding an Assembly reference that contains the namespace Matrix.System to a Windows Service project, I'm now getting this error when compiling the service:

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'

The errors are generated in the service though:

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

and in the service setup project I'm getting this:

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

the NMS assembly is already in the setup project and everything was working fine until I added the Matrix.System assembly


回答1:


You can "root" the namespace like this:

using global::System.ComponentModel;

(Then get rid of the fully-qualified references in your code.)

Or if you really want to use fully-qualified namespaces:

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

This looks unrelated to the other dependency issue though.

My guess is that in the same class you've got:

using Matrix;

otherwise I wouldn't expect it to be a problem in the first place.



来源:https://stackoverflow.com/questions/11373553/the-type-or-namespace-name-componentmodel-does-not-exist-in-the-namespace-afte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!