Creating StrongName and develop Com / Assembly in C#.Net
- Create a new Project Class Library
- 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>
- Type sn -k keyname.snk, This will create keyname.snk file in that folder.
- 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.
- Goto the signing tab and check Sign the assembly, browse and point it to the ‘key.snk’ file.
- open the AssemblyInfo.cs , add [assembly: AssemblyKeyFileAttribute(@”..\..\key.snk”)]
- in the AssemblyInfo.cs set [assembly: ComVisible(true)], now copy the assembly GUID that was auto created with the file
- put [System.Runtime.InteropServices.GuidAttribute(”paste guid here”)] in your main class file in between the Namespace and Class.
- Build the solution.
- Register the Assembly. [”regasm xxxx.dll /tlb:xxxx.tlb /codebase xxxx” at the command prompt, while in the directory that contains xxxx.dll]
- 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:
Post a Comment