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
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqNXqoqxEcoPZ6l2UHQnJRbxfBMeDo68rGJ6HYw8ZRs70xSzyTvsFzR2hBVxWWBLvFReXXhnC7QprMyIom0wwPVfysUWy3t8gY4Hit-BqtvGBQUnfJmfLQa4SvIu0Hyx7-LFP2b-SpFNY/s320/1.gif)
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.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCYUhBFvatcAE3qOL2D0mAJ6lyl8fOlE3rhec19mU9FBi3BUztVhPkkBh_dgy7yz_8moN9tkwdJlsh9V4MbVkFVimPX8ioHCn_Y8-Cvz8qi_X8Z1h88SkbrnhsvlCWIP2zz5ExCKfGtaY/s320/3.gif)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhH7yTsWh7oV2hww7VE0xgFCJluFYuD1Jj_zEEObT7Mp5ztfARSUwjbzOPxsi7ejLMoIT3uNLothDQ_6Q5l0pMq9rzfToJQRLbcmTpTTzlv-JhRBl_wzODJLd686cLcRCeMBaLdLyhesYU/s320/4.gif)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTiBOj_a50SgO7MHAGtlWUHHoNKsYavCvGuhIe5g1KAQ0pXG_Qjm5aPwDcZdQt9jOf2pIP0Ek438nADACQRBf58FsMEpNpb9uIcbuVwFzCtOLtaEl4KiQ_YlWXD6tswkhsKEjT0oSN8UE/s320/5.gif)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguAAQQuyIlHAOqg7R-ID_eHY0gHYFddMd1FfiDDyp1dtgqByWmaSi8P8bwzCyyivrEPEpu4BoihAaTkO5uMp4BSXoRW9Ykchnv42DVhT-OBR-p_Wy3LCMdFz2BA5zYeXGEYoKiYldBIlk/s320/6.gif)
No comments:
Post a Comment