Type typename is not CLS-compliant, interface, tests and dependency injection

· March 5, 2008

OK - here is a strange one… [UPDATE ON THIS POST - SEE http://www.marcusoft.net/2008/03/real-answere-type-typename-is-not-cls.html]

We are using dependency injection to be able to inject mocked version of classes that the class we’re testing is using…. (oh, my god - requires another blog-post i think… i’ll get back).

So the first thing we did was to extract interfaces for all the methods the implementation is using. So far so good.

But when i mocked the implement ion of the interface we got a quite strange warning:

Type ‘KodBenamning’ is not CLS-compliant.

Apparently this occurs when a type is referenced by an interface (as parameter or return type) AND the type is not marked with


which, by the way is NOT default, of course…. So - the solution is to mark all your classes used by interface with CLSCompliant(true) and it will work…

Twitter, Facebook