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 crea开发者_JAVA技巧ting 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.
Have you tried simply installing & running VB6 in WinXP compatability mode?
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.
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 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
You might try to use /win32 option of tlbexp
on an x64 OS.
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?
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.
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.
精彩评论