Saturday, July 21, 2007

Assembly : Creating a Shared Assembly

Create a new “Class Library” project in Visual Studio
In Class1.cs add a public method that returns int or string
Compile the code to get a dll file in debug/bin folder
Start sn tool, generate key as: sn –k C:\mykey.snk
In Visual Studio, edit AssemblyInfo.cs file by adding reference to key file
Add reference to the key by adding [assembly: AssemblyKeyFile(“C:\mykey.snk”)]
Recompile the code and dll will be signed using the key provided
Install assembly to GAC using gacutil –I “C:\path\to\dll\dllfile.dll”
Test the assembly bu adding its dll’s reference in a project
Add it in using directive using namespace.className;

No comments:

Post a Comment