无法获得工作由VB6客户端引用VB.NET DLL的REG-免费方案 [英] Cannot get to work VB.NET DLL referenced by VB6 client in reg-free scenario

查看:485
本文介绍了无法获得工作由VB6客户端引用VB.NET DLL的REG-免费方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从VB6的客户端访问VB.NET DLL(.NET FX 4.0)在REG-免费方案。

我试图按照从例子中<一href="http://msdn.microsoft.com/en-us/library/ms973915.aspx">http://msdn.microsoft.com/en-us/library/ms973915.aspx,但没有成功。我下载的来源(文章链接),编译,没有成功(错误信息:运行时错误'-2146234341(8013101b)':自动化错误)。使用注册的DLL VB.NET工程从VB6 IDE中运行

我想那里的.NET的DLL作为COM类中创建的其他例子(使用VS2010COM类模板),具有明显的被引用的DLL嵌入或不是,但没有为我工作。

有人可以提供一些简单的源$ C ​​$ C与使用VB6客户端REG-免费方案VB.NET的DLL(.NET FX V4)?

的体现例子

感谢很多提前。

解决方案
  

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

您的问题没有什么关系清单,你需要首先解决这一问题之一。错误code是COR_E_NEWER_RUNTIME。换句话说,你的[标记有ComVisible特性]类不能被加载,因为它依赖于CLR版本4和程序已经加载CLR版本2最有可能的,因为另一个[标记有ComVisible特性]类问的第一。它要求第2版。

您将需要强制CLR版本4中得到加载,甚至当有人询问版本2,应该是这样一个app.exe.config文件:

 &lt;结构&GT;
  &LT;启动useLegacyV2RuntimeActivati​​onPolicy =真正的&GT;
    &LT; supportedRuntime版本=V4.0/&GT;
  &LT; /启动&GT;
&LT; /结构&gt;
 

给它相同的名称VB6的exe文件(如foo.exe.config匹配foo.exe的),并把它放在同一个目录下.exe文件。如果你想使用VB6的IDE来调试使用这个库,那么你还需要vb6.exe.config在C您的VB6 code:\ Program Files文件\微软的Visual Studio \ VB98

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

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.

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.

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?

Thanks much in advance.

解决方案

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

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.

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>

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

这篇关于无法获得工作由VB6客户端引用VB.NET DLL的REG-免费方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆