互操作的自动化错误 [英] Automation error with interop

查看:114
本文介绍了互操作的自动化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近不得不重建为从VB6调用而创建的C#互操作。我已经用regasm注册了它(使用代码库开关),并将tlb添加为对VB6项目的引用,但是当我尝试调用它时,出现以下自动化错误:-2146232832(0x80131600)

I have recently had to rebuild a C# interop created for calling from VB6. I have registered it with regasm (using codebase switch) and added the tlb as a reference to the VB6 project but when I attempt to call it I get the following automation error: -2146232832 (0x80131600)

如果我以完全相同的方式注册现有的interop dll并将其添加到我的项目中,则可以正常工作。我能想到的唯一区别是该项目从VS8升级到了VS9(虽然是相同的.net版本),并且我现在正在64位计算机上编译(我知道这是有问题的)。我将项目设置为x86,但是仍然出现自动化错误。

If I register the existing interop dll in exactly the same way and add to my project, it works fine. The only differences I can think of are that the project has since been upgraded from VS8 to VS9 (same .net version though), and I'm now compiling on a 64-bit machine (which I know there are issues around this). I have set the project to compile as x86 but I still get the automation error.

任何想法?

推荐答案

您的C#代码引发了异常,没有被捕获。具体来说就是ApplicationException。这是框架代码永远不会抛出的异常,它必须位于您的C#源代码中。

Your C# code is throwing an exception and it isn't being caught. Specifically an ApplicationException. That's an exception that the framework code never throws, it must be located in your C# source code.

如果找不到该代码,则需要调试代码。问题。使用项目+属性的调试选项卡来执行此操作。选择启动外部程序,然后将其指向c:\program files\microsoft visual studio\vb98\vb6.exe。然后,单击调试+异常,选中 CLR异常的抛出复选框。

You'll need to debug the code if you can't locate the problem. Do so with Project + Properties, Debug tab. Select "Start external program" and point it to c:\program files\microsoft visual studio\vb98\vb6.exe. Then Debug + Exceptions, tick the Thrown checkbox for CLR exceptions.

现在可以按F5键,VB6 IDE开始运行。加载您的VB6项目并重现该问题。调试器在引发异常的C#代码行处停止。

You can now press F5 and the VB6 IDE start running. Load your VB6 project and reproduce the problem. The debugger stops at the line of C# code that throws the exception.

这篇关于互操作的自动化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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