Issuing AfxMessageBox

J

jlea

I have some legacy code wrapped in a .NET managed assembly that I'm using
from within an asp web application and all works fine until the legacy code
detects an error during a function call on an object and it tries to issue
an AfxMessageBox: The browser (IE) hangs.

How does one deal with this situation in a web application? I have a
try-catch in the aspx.cs but it never gets to the catch block.

Thanks.

Jon Lea.
 
S

Scott Allen

Hi Jon:

Unfortunately, AfxMessageBox will be the kiss of death in a web
application. The message box will appear on a hidden desktop and wait
for someone to click and close it.

The best solution would be to recompile the legacy code to be server
friendly (no calls to APIs requiring interactive UI). Either this or
porting the legacy code to .NET.

If that's impossible, you might be able to do something by hooking /
intercepting API calls, but it's not something I'd suggest doing until
it is the last option. If you google for keywords like: intercept hook
thunk win32 api, you'll find some research and articles on the
subject, and there are some commercial toolkits to help also.
 
J

jlea

Scott - thanks for the good info; I was afraid this might be the case.

I was thinking of percolating a return code up through the legacy code and
then have the client issue an appropriate error message depending on the
application: AfxMesssageBox or text string in a web page since the legacy
code is used for Win32/MFC apps in addition to web apps. This will take time
also but less than re-writing a bunch of code.

Jon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top