How to get custom error message in COM interop (COM calling .NET)?

How to get custom error message in COM interop (COM calling .NET)?

Post by Oran Halbertha » Thu, 19 Sep 2002 01:08:58



Hi All,

I have a small question about .NET class COM wrappers.

I'm calling a .NET class from a C++ client (No problems so far J)

The #import directive in C++ creates the COM wrapper functions and throws a
COM exception if the HRESULT fails (normal .tli)

In the .NET class library I implemented a hierarchy of exception classes
specific to my class library (all derived from ApplicationException) and I
set the HRESULT of each of these classes to a custom HRESULT (in the
constructor).

I would like to also set the message string of these errors.

When the _com_error reaches the C++ client then e.ErrorMessage() returns a
pre-built message for the HRESULT that I specified in the exception class'
constructor.

Is there a way to set this to a custom message?

Thanks in advance
Oran

 
 
 

1. Java COM Interop / J++ COM Interop

Hi all,

1. I create a VB 6.0 DLL prjAlfa with one class clsBeta
2. I use tlbimp prjAlfa.dll /out: prjAlfaInterop.dll to generate a DLL file to be used in .NET framework
3. I register prjAlfa.dll using regsvr32
4. I reference prjAlfaInterop in my C# application
5. in my Application, I write using prjAlfa;
6. I create an object "public prjAlfa._clsBeta objMath"
7. in the constructor of my form, I write "objMath = new prjAlfa.clsBeta();"
8. I can invoke any method on this object.

Here's my question:

I've followed exactly the same procedure except that I wrote a J++ COM DLL instead of a VB 6.0 COM DLL.

1. I create a J++ COM DLL prjAlfa with one class clsBeta
2. I use tlbimp prjAlfa.dll /out: prjAlfaInterop.dll to generate a DLL file to be used in .NET framework
3. I register prjAlfa.dll using regsvr32
4. I reference prjAlfaInterop in my C# application
5. in my Application, I write using prjAlfa;
6. I create an object "public prjAlfa.clsBeta_Dispatch objMath"
7. in the constructor of my form, I write "objMath = new prjAlfa.clsBeta();"
8. I canNOT invoke any method on this object.

Unfortunately, I always get the error message System.VTablesNotSupportedException which has as it's message prjAlfa.clsBeta_Dispatch, a COM dispatch only interface, only supports late binding calls.

Does anyone have any idea what I'm missing here??

Your help would be greatly appreciated!!
--
Sent via http://csharpindex.com
C# Index to resources

2. Media sense error while installing 3.3.on black next

3. COM Interop Sample 2: getting RegAsm errors...

4. Install not working

5. Failure when passing COM object through InterOp to .NET COM object

6. unable to access floppy&hard together

7. Error calling Web Service Client class via COM Interop

8. Getif 2.2

9. Painfully Slow .NET/COM Interop + Calling C++ DLL

10. COM client calls .NET server which calls .NET server : does not work

11. Creating Office Managed COM Add-Ins with Visual Studio .NET

12. Outlook COM Add-ins With .NET

13. Outlook 2002 COM Add-ins in VS.Net RTM