views:

795

answers:

3

Hi all.

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"&gt;
  <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>
A: 

Your code sample appears to be the manifest for the COM object DLL. Do you have a manifest for the main program too? It needs one that lists the other object as a dependency.

In answering an earlier question on this topic, my test was a C# program that used an old ActiveX control supplied with VB5/VB6. The manifest for my main program looked like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
  manifestVersion="1.0">
<assemblyIdentity
            type = "win32"
            name = "client"
            version = "1.0.0.0" />
<dependency>
            <dependentAssembly>
                        <assemblyIdentity
                                    type="win32"
                                    name="MSFLXGRD.X"
                                    version="6.1.97.82" />
            </dependentAssembly>
</dependency>
</assembly>

The name attribute on the dependentAssembly/assemblyIdentity element should match the one in the manifest for the COM DLL. As you can see here it does not have to be an actual filename.

Another possible issue I see is you don't have a comInterfaceExternalProxyStub element in your manifest. A sample of that tag and a walkthrough of what else to do is in this article on MSDN: Registration-Free Activation of COM Components: A Walkthrough. Steps 6 and 7 talk about creating the two manifests.

Tim Farley
A: 

Thanks for the response.

The manifest I added is auto-generated from the .NET console application. A manifest isn't being generated for the COM DLL itself. I'll check out the walkthrough and see if that provides any answers.

Matt Roberts
+1  A: 

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://code.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.