Avatar of StanChart
StanChart

asked on 

Funky COM error

Hi,
I have an application that calls functions in other applications using COM.  Whenever I call such a function, I always put a try {} catch (_com_error &er) {} around it.  Whenever there is an error, I display a message box with er.Description() on it.  

I received an email from one of my app users who received an error where er.Description() had all sorts of funky characters in it which leads me to believe that there was some sort of corruption.

Anyone know how/why this would happen?
C++

Avatar of undefined
Last Comment
Computer101
Avatar of bijopuli
bijopuli
Flag of India image

Hi StanChart

Just try this function to display ur message .

er.ErrorMessage( );

eg:

AfxMessageBox(er.ErrorMessage( ));

Regards
Bijo.
Avatar of StanChart
StanChart

ASKER

Either way, the message would have contained garbage data.  I'm interested in finding out why it contained that data.  All other times, the message displays a valid error.
Avatar of StanChart
StanChart

ASKER

I use er.Description because I add other text to the message.
ASKER CERTIFIED SOLUTION
Avatar of bijopuli
bijopuli
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of jkr
jkr
Flag of Germany image

Check all the places where your throw a _com_error and have a close look at those where you build a complex error message with parameters - you will most likely find the culprit there, with one of these parameters being either screwed up or invalid.
Avatar of alexcohn
alexcohn
Flag of Israel image

Hi StanChart, as Bijo pointed out there are many strange things that could happen to e.Description while building the MessageBox. Therefore it could be helpful if you could post the piece of code that displays the message box.

In the meanwhile, let me make a wild guess: could it be so that the user works with some strange language version of WiIndows, and the fonts he have cannot render the message correctly?
Avatar of StanChart
StanChart

ASKER

The code looks something like this:

try
{
      // some code
}
catch (_com_error &er) {
      CString error =
            CString("There was an error ... ") +
            CString("on ... \"") + CString(m_pMyPtr->GetName()) + CString("\".\n\n") +
            CString(string(er.Description()).c_str()) + CString("\n") +
            CString(er.ErrorMessage());
      MessageBox(NULL, error, "My App Error", MB_APPLMODAL|MB_ICONERROR|MB_OK);
      return FALSE;
}

Let me know if you spot an error.
SOLUTION
Avatar of alexcohn
alexcohn
Flag of Israel image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of SeanDurkin
SeanDurkin
Flag of United States of America image

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:
  Split: alexcohn {http:#18637089} & bijopuli {http:#18625195}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Sean Durkin
Experts Exchange Cleanup Volunteer
Avatar of Computer101
Computer101
Flag of United States of America image

Forced accept.

Computer101
EE Admin
C++
C++

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

58K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo