运行时错误-2146234341(8013101b)使用清单从VB.NET到VB6的自动化错误?

问题描述:

在无注册情况下,我试图从VB6客户端访问VB.NET DLL(.NET FX 4.0)。

I am trying to access a VB.NET DLL (.NET FX 4.0) from a VB6 client in a reg-free scenario.

我尝试遵循来自http://msdn.microsoft.com/en-us/library/ms973915 .aspx ,但没有成功。我下载了文章中的链接并进行了编译,但没有成功(错误消息:运行时错误'-2146234341(8013101b)':自动化错误。)使用已注册的VB.NET DLL从VB6 IDE运行。

I tried to follow the example from http://msdn.microsoft.com/en-us/library/ms973915.aspx, but with no success. I downloaded (link in the article) the sources and compiled, no success (error message: Run-time error '-2146234341 (8013101b)': Automation error"). Running from VB6 IDE using registered VB.NET DLL works.

我尝试了其他示例,其中将.NET DLL创建为COM类(使用VS2010中的 COM类模板),并嵌入或未嵌入引用DLL的清单。

I tried other examples where the .NET DLL is created as a COM Class (using "COM Class" template from VS2010), with manifest for referenced DLL embedded or not, but nothing worked for me.

有人可以提供一些简单的源代码,其中包括在无注册情况下在VB6客户端中使用的VB.NET DLL(.NET FX v4)清单示例吗?

Can somebody provide some simple source code with manifests example of VB.NET DLL (.NET FX v4) used in VB6 client in reg-free scenario?

非常感谢。


运行时错误'-2146234341(8013101b)':自动化错误

Run-time error '-2146234341 (8013101b)': Automation error

您的问题与以下内容无关清单中,您需要首先修复此错误。错误代码为COR_E_NEWER_RUNTIME。换句话说,您的[ComVisible]类无法加载,因为它取决于CLR版本4。程序已经很可能已经加载了版本2的CLR,因为首先需要另一个[ComVisible]类。它要求版本2。

Your problem doesn't have anything to do with a manifest, you'll need to fix this one first. The error code is COR_E_NEWER_RUNTIME. In other words, your [ComVisible] class cannot be loaded because it depends on CLR version 4. And the program has already loaded the CLR, version 2 most likely, because another [ComVisible] class asked first. And it asked for version 2.

您将需要一个app.exe.config文件,该文件将强制加载CLR版本4,即使有人要求版本2。看起来应该像这样:

You'll need an app.exe.config file that forces CLR version 4 to get loaded, even when somebody asks for version 2. It should look like this:

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
</configuration>

为它提供与vb6 exe相同的名称(例如 foo.exe.config以匹配 foo.exe),然后将其与.exe放在同一目录中。如果要使用VB6 IDE调试使用此库的vb6代码,则还需要在c:\program files\microsoft visual studio\vb98

Give it the same name as the vb6 exe (like "foo.exe.config" to match "foo.exe") and put it in the same directory as the .exe. If you want to use the VB6 IDE to debug your vb6 code that uses this library then you also need vb6.exe.config in c:\program files\microsoft visual studio\vb98