O'Reilly logo

Access™ 2007 VBA Programmer's Reference by Armen Stein, Geoffrey Griffith, Rob Cooper, Teresa Hennig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C.3. Using Managed Code in Access

There are two uses for the managed code you created. First, you want to be able to write to the Windows event log in your Access application. Second, you want to use the COM add-in to add the Workgroup Administrator to the Access Ribbon. To use these components from other computers, you'll need to take a few extra steps to properly register the control.

C.3.1. Registering Managed Code

When you build and run assemblies for COM Interop on a development machine, Visual Studio takes care of the registration for you. However, unless you use a setup package such as the one generated when you create a COM add-in project, there are a few steps you have to take to use managed code on a different machine.

To make an assembly available to all applications on the machine, you can install an assembly to the GAC. That requires that you use the Strong Name utility and sign the assembly. Once the assembly is installed to the GAC, it can be used by other managed code on the machine.

To use the Strong Name utility to generate a key file, enter the following at the command line:

sn  -k "YourFileName.snk"

To sign the assembly, check Sign The Assembly in the Properties dialog box for the project in Visual Studio and browse to the .snk file that was created using the Strong Name tool.

If you don't want to install your assembly into the GAC, you can use the regasm utility as follows (these steps require the Microsoft .NET Framework on the target machine):

  1. Copy the managed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required