Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Avoid DLL Hell with Registration-free COM : Page 2

Years of frustration with managing multiple versions of COM components is finally being addressed, thanks to a new component deployment mechanism from Microsoft called Reg-free COM.


advertisement
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 COM—for now, Reg-free COM is strictly runtime.

Back at the command line, navigate to the sample code folder and type the following command:

regsvr32 WaveOut.ocx

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 control—the same information that was previously stored in the registry.

Here's a portion of the manifest:

<file name="WaveOut.ocx" asmv2:size="28160"> <hash xmlns="urn:schemas-microsoft-com:asm.v2"> <dsig:Transforms> <dsig:Transform Algorithm= "urn:schemas-microsoft-com:HashTransforms.Identity" /> </dsig:Transforms> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> <dsig:DigestValue>7CQJz4x0edO3IsPI6RJ+BlX0m2M= </dsig:DigestValue> </hash> <typelib tlbid="{b5ee8904-c4f5-4256-adba-7b4a300155cc}" version="1.0" helpdir="D:\code\Projects\WaveOut\release\WaveOut.hlp" resourceid="0" flags="CONTROL,HASDISKIMAGE" /> <comClass clsid="{4110cc98-f22a-484c-8b96-8dfe76899360}" threadingModel="Apartment" tlbid="{b5ee8904-c4f5-4256-adba-7b4a300155cc}" progid="WAVEOUT.WaveOutCtrl.1" description="WaveOut Control" /> </file>

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. Keep it legal. Third-party COM components (including Office) are not typically redistributable royalty-free.


John Douglas is the founder and Director of Mycos Technologies, a .NET-centric outsourcing company and Microsoft Certified Partner in the Custom Development Solutions Competency located in Chiang Mai, Thailand.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap