30.8.08

Creating StrongName and develop Com / Assembly in C#.Net

  1. Create a new Project Class Library

  2. Open .net command prompt andGo to the folder contanig DLL ie. navigate to the project’s folder eg: E:\Test Application\AssenblyLibry\AssenblyLibry\bin\Debug>

  3. Type sn -k keyname.snk, This will create keyname.snk file in that folder.

  4. A Properties folder with an AssemblyInfo.cs file was created right click on the folder and open properties. The default should be ‘Class Library’ / Open the assemblyinfo.cs file of project, Type file path in this tag [assembly:AssemblyKeyFile@"E:\hemant\practice\HP\bin\Debug\HP.snk")] Build application, finally your strong name created for your DLL.

  5. Goto the signing tab and check Sign the assembly, browse and point it to the ‘key.snk’ file.

  6. open the AssemblyInfo.cs , add [assembly: AssemblyKeyFileAttribute(@”..\..\key.snk”)]

  7. in the AssemblyInfo.cs set [assembly: ComVisible(true)], now copy the assembly GUID that was auto created with the file

  8. put [System.Runtime.InteropServices.GuidAttribute(”paste guid here”)] in your main class file in between the Namespace and Class.

  9. Build the solution.

  10. Register the Assembly. [”regasm xxxx.dll /tlb:xxxx.tlb /codebase xxxx” at the command prompt, while in the directory that contains xxxx.dll]

  11. The assembly is now accessible using COM
    Steps for Installing in GAC
  • After giving strong name in .net command prompt type gacutil in DLL path this will install file in assembly.
  • Copy the DLL file C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 folder
  • You can add references to another project using .net tab.




























No comments: