17

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)?

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
user210757
  • 6,996
  • 17
  • 66
  • 115
  • At worst case consider rewriting the VB6 code now, its becoming obvious VB6 apps probably wont run on Windows 8 (unless MS continue to release the VB6 runtime with the OS) and with all the 128bit OS fuss with Windows 9 I think we are going to see the end of 32bit apps, unless you use a VM – Jeremy Thompson Feb 12 '11 at 00:06
  • @Jeremy Thompson - it is third party code, not my decision - i don't think we'll see the end of 32 bit code anytime soon – user210757 Apr 01 '11 at 18:09
  • @jeremy Microsoft did in fact release the VB6 runtime with Windows 8. The last couple of Windows releases have been the same: scary statements from MS saying they have "no plans" to include the runtime, but then when it comes to the crunch, they do just that. – MarkJ Jul 28 '13 at 19:37

8 Answers8

1

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.

Eugene Talagrand
  • 2,214
  • 1
  • 14
  • 16
  • i create my own resource file pointed to the manifest with an RC file, and embed this into the dll. I do get empty results from sxstrace, what do you mean by updating the timetstamp of VB6.exe? – user210757 Jan 10 '11 at 15:30
  • If you navigate to the file in Explorer, and open up the file properties, there should be a "Modified: " field with a date displayed. If you update the manifest inside VB6.exe, you should make sure this date has been updated as well. One way to do that is to use a "touch.exe" type utility if the compiler has not already. You can find many "touch.exe" implementations for Windows through a search engine, though I've personally only tried the one from UnxUtils. – Eugene Talagrand Jan 12 '11 at 07:36
  • when you say VB6.exe, are you saying an executable/dll written in VB6? not the actual IDE? – user210757 Jan 12 '11 at 15:21
  • Yes, I'm just echoing the terminology from the question. – Eugene Talagrand Jan 12 '11 at 18:59
  • ok, i'm actually talking about the IDE - loading .NET dlls with the VB6 devenv so I can debug VB6 code that uses them. interestingly, I can load the .net when the standalone vb6/dll produced - just not when debugging in VB6 – user210757 Jan 13 '11 at 15:27
1

The first thing that springs to mind is that it is worthwhile to try and sign the .net code. It may be that implicitly some higher level of security is applied on win7 64 bit that requires signed assembly references.

Furthermore you can try to narrow down the problem by (in no particular order)

  • label the program to run as administrator and retry.
  • label the program to run in "xp/win2k compatibilty mode"
  • run it in dependencywalker (it has an option to simulate program load, and will log errors)

Good luck!

  • i did not have a chance to try this and running in compatibility mode seemed to get me up and running but I think this is a very valid suggestion and maybe a better solution. maybe when i have a chance i will try and let you know the results. thanks – user210757 Apr 01 '11 at 19:02
1

I was doing this hybrid debugging the other day and got the error: ''ActiveX Component Can't Create Object.'' I suggest you follow this article Debugging Hybrid Visual Basic 6.0/Visual Basic .NET Applications and make sure a bare bones example works on your Win7 PC ( I reaalise it works with regasm). Then with the REG FREE bit, I researched the following links: .NET Object from VB6 without use of regasm.exe? and here Registration-Free Activation of .NET-Based Components: A Walkthrough

Community
  • 1
  • 1
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
1

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

hillbilly
  • 34
  • 2
  • marked as answer - this seemed to resolve for me (running in xp sp2 mode)! not to say any of the other suggestions would not have worked, i just have not had time to test all of them. thanks for all the help! – user210757 Apr 01 '11 at 19:00
0

You might try to use /win32 option of tlbexp on an x64 OS.

wqw
  • 11,771
  • 1
  • 33
  • 41
0

From this blog post

you can use SxsTrace to help debug the problem. To start trace run “SxsTrace Trace -logfile:SxsTrace.etl” to convert the log file to something you can view run “SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt”.

Have you tried that?

An other thing is that on Vista/Windows 7 you can easily run into UAC did you check that?

Emond
  • 50,210
  • 11
  • 84
  • 115
0

Regasm does a lot more than just generate the TLB or needed registry keys.

For instance, it can generate COM visible interfaces, based on COM visible types. Regasm will do this when the COM visible type does not implement an interface for instance.

Do you have any COM visible types that do not implement an interface (or do not define the COM interface by using the ComDefaultInterfaceAttribute)?

If so, this may be your problem.

Alfred Myers
  • 6,384
  • 1
  • 40
  • 68
Simon Smeets
  • 581
  • 6
  • 17
  • I have COM visible interfaces that I implement. The classes that implement these interfaces are what I am trying to access through VB6, and what I "expose" in my manifest – user210757 Feb 15 '11 at 15:53
0

I have been able to succesfully use .Net classes from VB6 in Win 7-64 using manifests created by Side by Side Manifest Maker. It has a free trial.

Don't forget to include the .Net runtime version that your classes target. That may be your problem to begin with as Win 7 comes with .Net 4 Client Profile preinstalled only.

Dabblernl
  • 15,831
  • 18
  • 96
  • 148