1
votes

I have a COM component. I registered it using regsvr32 on my 32-bit XP machine. Now when i try to instantiate a class from it in my CONSOLE application, the application just terminates, without giving any exception. Any suggestion??

The COM dll is ABCServer.dll. The code that fails,

   try
   {
     ILookUp LP = new LookUp();
     ABCServer Svr = LP.LookUpServer(hostname, port);
   }
   catch(Exception ex)
   {
     Console.WriteLine(ex.message);
   }

Control never reaches line 2, while debugging when i click F10 when being on line 1, the application just terminates

1
Did you try using try..except? Show us some code please...Marco
It's worth posting the code for more claritys_nair
Did you check your eventlog for any errors?Polity
Does it also "just terminate" when you run it under debugger or does it actually produce an unhandled exception?Branko Dimitrijevic
@Marco he is working in C# try-execpt is only C/C++ right?Davide Piras

1 Answers

2
votes

The COM code probably calls the C/C++ abort() for some reason (or whatever the equivalent is in the COM DLL's implementation language). And since the COM server is in-process, that immediately kills the whole process.

Note that C++ exceptions cannot pass through the COM boundary (they must be explicitly "marshaled" via ISupportErrorInfo). If an exception was raised in the COM DLL but was not properly caught and handled by the COM DLL implementation code, this might have caused abort() to be called.

If you have debug information for COM DLL, you can try enabling unmanaged code debugging (from Debug tab of project properties, or through "Select" button in the Attach to Process dialog) and stepping into the native COM code to try and diagnose the root problem.