Automation error with interop

0

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??

c#
.net
com-interop
asked on Stack Overflow Aug 15, 2012 by RRM1000 • edited Sep 24, 2012 by Kate Gregory

1 Answer

2

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.

answered on Stack Overflow Aug 15, 2012 by Hans Passant

User contributions licensed under CC BY-SA 3.0