venerdì, giugno 13, 2008

Use an internal class from another assembly

In big projects many classes has marked as internal. Tipically they are classes for internal activities and nobody needs to reference them from outside the assemply.

But, when you're developing you need to call them directly for testing/debugging. But... you cannot do that. The classes are internal.

There is a solution: mark the assembly as "friend" of another. An example: 2 assembly. MyLib with namy internal classes. DevTestApp, the test/development application with reference to MyLib. In the MyLib source code add:

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("DevTestApp")]

Now, from DevTestApp you can use public and internal classes from MyLib.

More details:

Nessun commento: