Automation error with interop

大憨熊 提交于 2019-12-25 02:59:56

问题


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)

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.

Any ideas??


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/11973212/automation-error-with-interop

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