How to catch missing DLL errors

  • Thread starter Thread starter JohnR
  • Start date Start date
J

JohnR

Hi all, I have an application that uses a custom DLL. The DLL needs to be
in the same directory as the executable. If it's not I want to catch the
error and give a meaningful message to the user. Right now, the appl
immediately aborts with a cryptic "Application has generated an exception
that could not be handled" error.

the application starts in a STARTUP Module and then starts up the main form.
I've tried ON ERROR, TRY CATCH, all with no success. In the startup Module
I have a DIM stmt that needs to reference a singleton pattern class which
resides in the custom dll. Code is as follows:

Dim GlobalItems As GlobalLibraryVars = getGlobalVarsObject()
'GlobalLibraryVars is a singleton pattern class in the custom DLL

I am wondering if the system is processing the DIM statements before
executing the Sub Main() code, if so, how can I catch a missing DLL error???

Does anybody have any suggestions? This thing is really driving me crazy...

Thanks, John
 
Sorry for the duplicate post... I got an error on the original posting, and
thought it was lost...
 
If you have a reference to the DLL, then the application will try to load the
DLL as your exe loads. One way is to try loading the DLL via reflection,
which will allow you to catch the exception when you do an assembly.load.

Rgds,
Anand M
http://www.dotnetindia.com
 
Hi,

In addition to Anand's reply if you create a setup project to
install the app the msi will automatically check for the presence of the dll
when the application starts and reinstall the dll if missing.

Ken
----------------------------
 
JohnR said:
I have an application that uses a custom DLL. The DLL needs to be
in the same directory as the executable. If it's not I want to catch the
error

If you are loading the assembly yourself, you can catch this.

If it is being loaded "for you", because you have a reference to it
and are creating objects from it using New (which is what you'd
/normally/ do), then I don't think you can. The Exception gets
thrown [long] before any of /your/ code gets a look in.

Regards,
Phill W.
 
Back
Top