Faqs on asp.net,c#,vb.net and sqlserver2005

this blog covers all the Faqs related to .net technologies like asp.net,vb.net,c#.net,ajax,javascript and sqlserver2005.

Feb 29, 2008

Registering an Assembly in the GAC

Registering an Assembly in the GAC

1) Create an assembly key file Use the sn.exe tool to create a key file: sn -k StrongNameFile.snk If your path environment variables aren't set, you'll have to go to the C:\Program Files\Microsoft.NET\FrameworkSDK\Bin\ directory to run sn.exe) The filename "StrongNameFile.snk" can be any name you want.

2) Edit your assembly Now you have to add a tag which will link your assembly key to the assembly: using System.Reflection; [assembly:AssemblyKeyFile("StrongNameFile.snk")] Normally this is done in the utility AssemblyInfo.cs (vb) file.

3) Add your assembly to the GAC gacutil /i AssemblyFileName.dll To uninstall this assembly from the GAC, use the command: gacutil /u AssemblyFileName

4) (Opional) Add your assembly to machine.config Locate the tag (for web apps,under ////) Between the tags, enter: You can get the information for the assembly attribute, by running the gacutil /l command which will return a list of all the assemblies in the GAC. You will have to look for the one you just added and copy the entire line (less the Custom=XXX part at the end). At this point, you will be able to place this directive in your aspx pages. <%@Import Namespace="YourNamespace"%> or, you can set a reference in the Visual Studio IDE as you would with other GAC Assemblies.

Happy Programming

0 Comments:

Post a Comment

<< Home