How to: Install Assemblies in the Global Assembly Cache

The global assembly cache operates no differently in the .NET Compact Framework than in the full .NET Framework.

To install resources files such as DLLs into the global assembly cache

  1. Put the resource files in a directory on the device.

  2. Create a text file that lists each file and its path on a separate line.

  3. Save the text file with a .gac extension into the Windows directory on the device.

    Assembly files can be ANSI or UTF-8 encoded, but other Unicode encoding is not supported.

The following is an example of MyDlls.gac, which lists three files to install into the global assembly cache:

\Program Files\MyApp\MyDll1.Dll
\Program Files\MyApp\MyDll2.Dll
\Program Files\MyApp\MyDll3.Dll

The next time that you run your application, the .NET Compact Framework moves the files that you listed in the .gac text file into the global assembly cache. The files must be signed with strong names. Delay signing is not currently supported. Any changes to the .gac text file causes the following:

  • If you delete the .gac text file from the Windows directory, the files that it listed will be removed from the global assembly cache the next time that you run your application.

  • If you update the .gac text file, the .NET Compact Framework will update the files in the global assembly cache accordingly.

You cannot load assemblies with the same name. You must either change the names of the DLLs, or if the DLLs are strong named, put them in the global assembly cache and use the Load method with a full strong name.

You can verify that an assembly is strong named by opening a command line on the desktop and using the sn –V myAssembly.dll command. For more information about how to sign an assembly, see How to: Sign an Assembly with a Strong Name.

See Also

Concepts

Global Assembly Cache

Other Resources

Building Applications and Core Tasks in the .NET Compact Framework