improve my => 'code'
.. though it is not very well documented.
I have found it very useful to expose internal interfaces for unit test projects in order to initialize many types of objects at one time (when they all implement the same interface). Of course, I did not want to switch over the access modifier for the interfaces every time I wanted to run unit tests, so I used the InternalsVisibleAttribute
This attribute can also be very useful for types you want to expose to your own assemblies, but not to outside customers (as it may clutter up their design environment).
First thing you will need to do is fire up the Visual Studio 2005 Command Prompt, and go to the folder for the dll or exe for which you want to grant access.
Next you want to issue: sn.exe -t myDLL.dll myDLL.pub (substitute myDLL with the name of your dll)
Then you can extract the public key for your dll by issuing the following: sn.exe -tp mykey.pub
Take the output from this command (it will be about 240 characters) and insert the following into the AssemblyInfo.cs file in the dll whose internal types you want to publish:
[assembly: InternalsVisibleTo("mydll, PublicKey=892s000004800000940000000602000000240000525341312224000001001100e5dd149f
744f5928e87037e26c6f9a9154bcdb5bceee4041c119c0d500d559780596c6305bb1025392b1502558
cb5b468f13c46acf363619115bdd866835f95ddba349343483df54540dd49437a37699c6aafe42fdbc
c391a65907d38768c80c2b9c15cbc55d7ccca9aaa1713476910a1169c93a566541e5ba67b371920053
c8"]
Voila! Happy coding,
Jonathan
Tools Print Email Del.icio.us
Digg
reddit