madExcept in a COM server

delphi package - automated exception handling
Post Reply
FlagshipTech
Posts: 12
Joined: Sun Jan 18, 2009 1:47 am

madExcept in a COM server

Post by FlagshipTech »

A couple years ago madshi and I had a lengthy discussion about using madExcept in a COM server. My goals were (and still are) to:

(1) Get a stack trace for exceptions in the COM server.

(2) Intercept all exceptions within the COM server, and re-raise them as EOleExceptions with custom information stuffed into all the right fields. Specifically, I want to return a custom HResult to the caller indicating the general error type (which indicates whether the COM server instance should be released), and also return the stack trace (bugreport) in EOleException.Create's Source field.

I don't recall the reasons, but it seemed the only way I could accomplish this at the time was to wrap *every* method exposed by the COM server in a try..except block, which when an exception occurred, called a custom handler. The custom handler called a madExcept function to grab a bugreport (stack trace), created a custom HResult code, and re-raised the exception as my custom EOleException.

I haven't built a COM server for quite a while but now I need to work a lot in COM again, and I'm wondering if madExcept 3.x would simplify any of what I've described above.

(**) Specifically, would it eliminate the need to wrap every exposed method in a try...except block?

(***) And if so, by what approach (where in my code or "how" using madExcept methods) would I intercept the exception trapped by madExcept and re-raise it as my own custom exception?

I'm still using madExcept 2.7 for now...but would be willing to upgrade to 3.x if it would simplify my life.

What do you say, Mathias? (Or anyone...)
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Hey,

sorry for the very late reply!

To be honest, I don't have *any* real knowledge about COM server programming. Back when we talked about this topic, you probably had to explain all the juicy details to me to make me understand what we were talking about, anyway.

I don't think that madExcept 3 will be much different compared to madExcept 2 in terms of COM server handling. But then I don't really know for sure since I don't know (anymore?) how COM server works at all. Sorry, I wish I could be of more help!! :oops:
FlagshipTech
Posts: 12
Joined: Sun Jan 18, 2009 1:47 am

Post by FlagshipTech »

madshi wrote: To be honest, I don't have *any* real knowledge about COM server programming....
Then you're not far behind me in your knowledge of COM.<g>

And I haven't worked it much since our discussion those several years ago (at that time I really *did* know something about COM). But lately I've had to write a COM server because of Vista--part of one of my apps needed process elevation for proper UAC interaction, and the way to do that is by writing an out-of-process COM server.

Anyway, I got the job done the "old" way: by wrapping every call in my own try..except handler, but relying on madExcept to grab a bug report.

(By the way I'm one of those folks who, if I could figure out how to grab Vista by the collar, would drag it out in the road and shoot it dead<g>...it has caused me countless hours of extra support time/incompatibility/rewrites/updates, all just to keep my apps running, not to add features customers really need.)

Thanks for your comments...and good to hear from you.

Mark Wilsdorf
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Because of Vista I had to rewrite my whole IPC solution. So I understand your frustration quite well. On the positive side, the new IPC solution also works in 64bit OSs while the old one did not. So it wasn't too much of an annoyance after all.
etwoss
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: madExcept in a COM server

Post by etwoss »

Hi

Did you find any solution for using MadExcept in a Com Server?

Eric
Post Reply