Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reg Free Com with VB6 on Windows 7

I have some .NET code I use from VB6 code. I have always developed this on an XP machine by creating a VB6.exe.manifest file that listed the dependent .NET assemblies.

For example, say my 2 .NET assemblies are Some.Assembly.A.dll and Some.Assembly.B.dll, here is what VB6.EXE.manifest looks like (I use version=1.1.0.0 below because that is the version I set on the .NET AssemblyVersion in AssemblyInfo.cs):

<?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.1.0.0" />
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
                  type="win32"
                  name="Some.Assembly.A"
                  version="1.1.0.0" />
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
                  type="win32"
                  name="Some.Assembly.B"
                  version="1.1.0.0" />
    </dependentAssembly>
  </dependency>
</assembly>

Then, along with the DLLs in the same directory, I have the assemblies and their own manifest files. Here is an example "Some.Assembly.A.dll.manifest":

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
  manifestVersion="1.0">
  <assemblyIdentity
      type="win32"
      name="Some.Assembly.A"
      version="1.1.0.0" />
  <clrClass
      clsid="{F1234567-1234-1234-1234-123456789012}"
      progid="Some.Assembly.A.Class1"
      threadingModel="Both"
      name="Some.Assembly.A.Class1" >
  </clrClass>
  <file name = "Some.Assembly.A.dll" />
</assembly>

I also run tlbexp on referenced DLLs to create TLB files, and this is what I reference in my VB6 project file.

I want to move to a Windows 7 64 BIT machine. Using the same methods, when I hit the VB6 code that instantiates the .NET object on the WIN7 machine I get

"ActiveX Component Can't Create Object."

On XP, it succeeds. If I purposely misspell the Dependent assembly in VB6.EXE.manifest - on XP I get

"This application has failed to start because teh application configuration is incorrect. Reinstalling the application may fix this problem."

On WIN7, VB6 just loads. It's like it ignores the manifest on WIN7, so I can't load my .NET object using REG FREE methods on WIN7. If I regasm the DLL, everything works.
Any ideas on how to make VB6 work with reg free com on WIN7 (64 BIT)?

like image 387
user210757 Avatar asked Dec 30 '10 17:12

user210757


2 Answers

Have you tried simply installing & running VB6 in WinXP compatability mode?

like image 166
hillbilly Avatar answered Oct 21 '22 17:10

hillbilly


If you are recompiling vb6.exe or otherwise processing it for the win7 machine, you should know that some of the newer development tools automatically embed a manifest so you may want to check for that (a quick way is to open up the executable in VS, and look for a resource RT_MANIFEST with id 1). If there's an embedded manifest, external manifests are ignored, which is possibly why when you edit the external manfiest, nothing happens and its contents are ignored.

Besides what Erno said about sxstrace (could you post the results you get from sxstrace?), make sure to update the timestamp of VB6.exe if the manifest is embedded into it, or VB6.exe.manifest otherwise. Vista + Win7 cache the contents of manifests, keyed off the timestamp of the root manifest so your local edits might not be getting picked up. If sxstrace is giving you blank results, update the timestamps and try again.

like image 20
Eugene Talagrand Avatar answered Oct 21 '22 19:10

Eugene Talagrand