Reg Free Com with VB6 on Windows 7

99封情书 提交于 2019-12-18 12:16:31

问题


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


回答1:


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




回答2:


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.




回答3:


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!




回答4:


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




回答5:


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




回答6:


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?




回答7:


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.




回答8:


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.



来源:https://stackoverflow.com/questions/4565000/reg-free-com-with-vb6-on-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!