LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with user message in CA_GetAutomationErrorString

I have a CVI DLL that calls a Delphi 6 COM server. When the COM server gets an error it raise an exception and put a message in it. In my call to my COM server in CVI I see that there was an error but when I call CA_GetAutomationErrorString it always return "Exception Occured". Is there a way to get the real exception message that was generated.
I do the same thing with a LabVIEW VI (call the same Delphi 6 COM server) and when I get an exception in my call I see the real error message in my error cluster in LabVIEW.

Is this normal for CVI that you can't get the real error message or is this a problem in 5.5 and it was corrected in later release...

Any information would be appreciated.

Gilles Hache
0 Kudos
Message 1 of 7
(2,706 Views)
Hello

I was able to retrive information from an atl server fairly easily, but i was using CVI 6.0, and it was a standard exception E_OUTOFMEMORY. If possible, could you post for COM dll, I can try it out and tell you what i find

Thanks
Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 7
(2,706 Views)
Hi,
I have include a test com server (Project2.exe) in the zip file with the ActiveX wrapper for CVI.

Run the Project2.exe once to register it and after that use the wrapper (or generate new one) to call the "Method1" function in the COM server. That function will raise an exception with the message "Got a user error"
If the error code is not 0 after the call to Method1 you can do a CA_GetAutotmationErrorString and the message that I get is always: "Exception Occured".

I use the Borland compatibility mode. If your mode is different you can remove the .obj file in the wrapper.

Hope you can explain me what's happening.
0 Kudos
Message 3 of 7
(2,706 Views)
I got an exception when i tried to run the COM server (just by doule clicking). Would i need some external files to run this correctly?
With LabVIEW, this exception occurs at open automation reference, not when i invoke the method

Bilal
Bilal Durrani
NI
0 Kudos
Message 4 of 7
(2,706 Views)
Here is a new Project2.exe COM server. In the last one I forgot to remove some include code that was not available on your machine.

I have also tried my code with CVI 6.0 and it still create the same behavior ("Exception Occured" for any user define exception message)

Gilles
0 Kudos
Message 5 of 7
(2,706 Views)
Sorry, I should have seen this before. For throwing custom error messages, you have to make use of the ERRORINFO structure which stores this information. The HRESULT is not what contains the information. So in the case of your server, try the following

status = Project2_NewITestServer (NULL, 1, LOCALE_NEUTRAL, 0,
&objHandle);

status = Project2_ITestServerMethod1 (objHandle, &errorInfo);

//Displays a popup box
CA_DisplayErrorInfo (objHandle, NULL, status, &errorInfo);

if(FAILED(status))
printf("%s\n",errorInfo.description);

I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 6 of 7
(2,706 Views)
It works, thank you very much for your help.

Gilles
0 Kudos
Message 7 of 7
(2,706 Views)