Reg-Free COM not working for me

comnetregfreecom

I am trying to see if Reg-Free COM is something we can use in our web application to ease deployment of legacy COM components. However, before I get onto looking into things like using it for Interop situations, I can't get a simple test to work. Here's what I have done :-

1) Create a new VB ActiveX DLL project. Left all options as default apart from turning on binary compatibility. Added a class with a simple method called "SayHello".
2) Create a new c# Console app in Vs.NET 2008 (SP1). Set the CPU to x86, and added a reference to my COM DLL.
3) Turned on "Isolated" for the reference
4) Call my SayHello method from the c# console app – all works.
5) Manually un-register the COM dll with regsvr32 /u
6) Try running the console app again. The app fails with a COM error because it can't find the COM registration information. I can confirm that the manifest is present (pasted below)

I'm running this on Vista, 64Bit, if that makes a difference.

Thanks for any pointers.

<?xml version="1.0" encoding="utf-8"?>
<assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity name="TestRegFreeCom.exe" version="1.0.0.0" processorArchitecture="x86" type="win32" />
  <file name="TestProject.dll" asmv2:size="20480">
    <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>uIK8e9FAnH4SQwk6PRfrjdZHWuw=</dsig:DigestValue>
    </hash>
    <typelib tlbid="{08dcd362-63a1-424a-8c4e-e72dcda2a8e2}" version="1.0" helpdir="" resourceid="0" flags="HASDISKIMAGE" />
    <comClass clsid="{c540c43a-4d80-4c87-9091-dff664df0021}" tlbid="{08dcd362-63a1-424a-8c4e-e72dcda2a8e2}" progid="TestProject.Testy" />
  </file>
</assembly>

Best Answer

If you reference a .dll in your application, click on the referenced dll under references in your project, look at the properties and set Isolated to TRUE.

This will include the .dll in your project and your application will use the copy of the .dll included in your project.

To see a working Example of this look here:

http://archive.msdn.microsoft.com/SEHE

The .dll in question will need to be registered on the system where you build your application for this to work properly.