Sunday, August 8, 2010

Referencing an Assembly from Global Assembly Cache

In order to reference an seeembly from GAC. We have to have an assembly with a strong name, in case the assembly is not a strong named then you have to created a strong name for that assembly. follow this article for reference
http://www.kivela.be/index.php/2007/12/11/strong-signing-a-third-party-assembly-in-net/

After the strong name is assigned for any dll. If you try to reference any DLL at that point its reference is checked from GAC as per strong name or publick key token. If the strong name is matched with the SN for the DLL you are referenceing then you don't see the assemble in the bin of your project directory. else the DLL will be added to you BIN directory.

To add a reference

•In Solution Explorer, expand the project node to which a reference is to be added.
•Right-click the References node for the project and select Add Reference from the shortcut menu.
•To add a reference to a component or components, do the following:
•In the Add Reference dialog box, select the tab indicating the type of component to be referenced.
•In the top pane, select the component to be referenced, and then click the Select button.
Tip If the component you are looking for is not in the list, you may locate it using the Browse button.

The component referenced appears in the SelectedComponents pane of the dialog box.

•Repeat Step b for each additional component added.
•Click OK when references are all added.

To add assemblies to the Add References dialog box

•In Windows, click the Start button, click Run, then type regedit, to open the Registry Editor.
•Select the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\AssemblyFolders
•On the Edit menu, point to New, then, click Key.
•Enter a name for the key (for example, MyAssemblies).
•Select the (Default) value for the key that you just added.
•On the Edit menu, choose Modify.
•In the Edit String dialog box, select the Value data field and enter the full path to the folder where your assemblies are located.

To remove a reference

•In Solution Explorer, right-click the reference in the References node, and select Remove from the shortcut menu.
•By default, the Add References dialog box only lists assemblies that are in the Public Assemblies folder (Program Files\Microsoft Visual Studio .NET\Common7\IDE\Public Assemblies) or in the Global Assembly cache. You can add your own assemblies to the list by adding a registry key to specify their location

No comments:

Post a Comment