问题
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