views:

94

answers:

1

I maintain a program written in Delphi 6. It loads some bpl package files dynamically using SysUtils.LoadPackage. Often I change something in the program that causes a package to fail to load. When this happens a message box appears and then an exception is thrown. The message box and exception are separate.

Here's an example of the message box:

---------------------------
Connect Manager: ConnectManager.exe - Entry Point Not Found
---------------------------
The procedure entry point @Connectmanagerplugin@TConnectManagerPluginClassList@UnRegister$qqrp17System@TMetaClass could not be located in the dynamic link library ConnectManagerPack.bpl. 
---------------------------
OK   
---------------------------

And here's the exception:

---------------------------
Debugger Exception Notification
---------------------------
Project ConnectManager.exe raised exception class EPackageError with message 'Can't load package Projects.bpl.
The specified procedure could not be found'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------

I can't see how to stop the message box from appearing. Any ideas accepted gratefully.

+2  A: 

Solved!

I created a copy of SysUtils.LoadPackage in my application and edited this copy to pass a second param to SafeLoadLibrary.

So the call to SafeLoadLibrary now looks like:

Result := SafeLoadLibrary(Name, SEM_FAILCRITICALERRORS);

SetErrorMode helped.

cja
That will suppress the first error message. Good idea. The second error message is displayed by the debugger when your application raises an exception. After making this change, your program will still raise that exception. You can either [reconfigure the debugger](http://www.cs.wisc.edu/~rkennedy/exception-messages), or you can press the "continue" button on that message box and let your program catch the exception after the debugger's notification. Also, consider including `sem_NoOpenFileErrorBox` in your call to SafeLoadLibrary since that's the default.
Rob Kennedy