Reg Free Com with VB6.exe on Windows 7
Asked Answered
A

8

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

Accuracy answered 30/12, 2010 at 17:59 Comment(3)
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 VMExacerbate
@Jeremy Thompson - it is third party code, not my decision - i don't think we'll see the end of 32 bit code anytime soonAccuracy
@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.Navarre
B
1

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

Bootleg answered 24/2, 2011 at 16:16 Comment(1)
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!Accuracy
J
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.

Juggernaut answered 10/1, 2011 at 9:35 Comment(5)
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?Accuracy
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.Juggernaut
when you say VB6.exe, are you saying an executable/dll written in VB6? not the actual IDE?Accuracy
Yes, I'm just echoing the terminology from the question.Juggernaut
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 VB6Accuracy
D
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!

Dorsad answered 27/1, 2011 at 21:48 Comment(1)
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. thanksAccuracy
E
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

Exacerbate answered 12/2, 2011 at 0:22 Comment(0)
B
1

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

Bootleg answered 24/2, 2011 at 16:16 Comment(1)
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!Accuracy
F
0

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

Farlee answered 1/1, 2011 at 16:3 Comment(1)
I had high hopes for this suggestion but no such luck. I am compiling my .NET to x86 architecture also.Accuracy
S
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?

Shipworm answered 8/1, 2011 at 7:33 Comment(1)
i get an empty trace file with sxstrace. how would i check UAC - event viewer?Accuracy
R
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.

Radtke answered 14/2, 2011 at 13:28 Comment(1)
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 manifestAccuracy
T
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.

Thralldom answered 20/2, 2011 at 10:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.