Building for Reg-free COM
With Visual Studio.NET 2005, building registration free applications is simple. Before you open the FlashCards solution, however, you will have to register the WaveOut.ocx
control. Somewhat ironically, although you can launch a deployed application without registering COM controls, you do have to register COM components on development
machines where you're building applications that use Reg-free COMfor now, Reg-free COM is strictly runtime.
Back at the command line, navigate to the sample code folder and type the following command:
That command registers the component, so you can now load the FlashCards application from the /Reg
directory into Visual Studio.
From the Reg/FlashCards
folder, open the FlashCards solution file. In Solution Explorer, open the References
folder. When I added the ActiveX control WaveOut.ocx
to the application form (via Toolbox->Right Click->Choose Items->COM), VS added two references to the project: WaveOutLib and AxWaveOutLib. These two files are automatically generated by Visual Studio through a call to aximp.exe
to provide a wrapper for the ActiveX control. Set the isolated flag to "True" to allow for Reg-free deployment (see Figure 2
). You can select either DLL, as Visual Studio will update the other one to match automatically.
|Figure 2. Set COM Component Isolation: Here's the property setting to isolate an interop COM component for a Reg-free build.|
Now, when you build (either release or debug) the FlashCards application, VS will also create an XML manifest file named FlashCards.exe.Manifest
that contains the ClassID and type library information for the controlthe same information that was previously stored in the registry.
Here's a portion of the manifest:
<file name="WaveOut.ocx" asmv2:size="28160">
description="WaveOut Control" />
With the manifest created, simply copying the release folder (using XCOPY) to any client will let that client use the control without any entries in the Registry. Copying the files is the only step required for interop deployment, but be sure to review the checklist in the next section before using Reg-free COM.
Reg-free COM Checklist
The end-user's operating system must be Windows 2003 Server or Windows XP with Service Pack 2. Reg-free COM will not work on earlier OSs or earlier XP service packs.
Verify that the COM component is registered on the development box that does the build. The component must be properly registered for Visual Studio to generate the manifest information required to use Reg-free COM.
Do not use Reg-free COM unless you wish the component to be isolated. In other words, if you want to share the component with other applications, you must make sure it's properly registered on the target machines.
Test on a clean machine (one where the components are not registered). That's because you won't get a warning if Reg-free COM deployments are actually accessing the registered version of a COM control. A clean machine is the best way to verify that an application using Reg-free COM is functioning as expected.
Think through dependencies. For Reg-free COM, use only components that can function in isolation. For example, graphics components make good candidates for isolation, but system files do not.
Keep it legal. Third-party COM components (including Office) are not typically redistributable royalty-free.