Making internal types visible to another assembly

You just have to sign the assembly that wants to use the internals with a key (usually a .snk file) and put this in the AssemblyInfo.cs

 

[assemblyInternalsVisibleTo(“(name of assembly that wants to see the internals), PublicKey=(public key)”)]

 

Notice that you have to put the public key and the name of the assembly that wants to see the internals. This is especially interesting when Unit Testing, since you may want to inject dependencies using some internal constructor and internal types.

 

The extract the public key you may use the sn.exe (Strong Name Utility) that comes with Visual Studio and can be used from the Developer Command Prompt (serach “Visual Studio Tools” using the Windows Search J)

 

Happy testing, buddies!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s