将 .NET 对象从 VB6 传递到 .NET 的问题 [英] Issue passing .NET object from VB6 to .NET

查看:28
本文介绍了将 .NET 对象从 VB6 传递到 .NET 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个由第三方创建的 .NET dll A".它通过 tlb 向我们的 VB6 exe 应用程序公开类.

We have a .NET dll "A" that is created by a third party. It exposes classes through a tlb to our VB6 exe application.

我们还有自己的 .NET dll B",它引用 .NET dll A".B"还通过 tlb 向我们的 VB6 exe 应用程序公开类.

We also have our own .NET dll "B" that references .NET dll "A". "B" also exposes classes to our VB6 exe application through a tlb.

现在,VB6 应用程序在 VB6 代码中使用任一库中的类都没有问题,直到我们尝试在B"中调用具有A"参数类型的函数.在这种情况下,我们会收到错误 430 或错误提示 无法将 'system.__comobject' 类型的 com 对象转换为 'Type.From.Dll.A' 类型"

Now, the VB6 application has no problem using classes from either library in the VB6 code until we try to call a function in "B" that has a parameter type from "A". In that case, we get an error 430 or an error saying "unable to cast com object of type 'system.__comobject' to type 'Type.From.Dll.A'"

这可能是什么原因造成的?这正常吗?

What could be causing this? Is this normal?

推荐答案

您的问题是您所说的不同的 NET 版本.

You problem is the different NET versions as you said.

在版本 4 中,NET 团队引入了 进程内并行执行

In version 4 , the NET team introduced the In-Process Side-by-Side Execution

这样,您可以在应用程序中运行不同版本的 CLR.

With this you can have different versions of the CLR running in your application.

但这不是你想要的,所以我认为你应该关闭这个功能,使用 app.config 文件:

But that is not what you want, so I think you should turn this feature off, using an app.config file:

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

请注意,当您使用 VB6 IDE 时,需要 app.config 的进程是 VB6.exe,因此我还将该 app.config 复制到 VB6 文件夹并将其重命名为 VB6.exe.配置.查看此答案

Please note, that while you are using the VB6 IDE, the process that requires an app.config is the VB6.exe, so I would also copy that app.config to the VB6 folder and renamed it as VB6.exe.config. See this answer

这篇关于将 .NET 对象从 VB6 传递到 .NET 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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