PC Review


Reply
Thread Tools Rate Thread

How to catch missing DLL errors

 
 
JohnR
Guest
Posts: n/a
 
      22nd Mar 2005
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


 
Reply With Quote
 
 
 
 
JohnR
Guest
Posts: n/a
 
      22nd Mar 2005
Sorry for the duplicate post... I got an error on the original posting, and
thought it was lost...


"JohnR" <(E-Mail Removed)> wrote in message
newsyN%d.12668$Ue6.1777@trndny04...
> 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
>
>



 
Reply With Quote
 
=?Utf-8?B?QW5hbmRbTVZQXQ==?=
Guest
Posts: n/a
 
      22nd Mar 2005
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

"JohnR" wrote:

> 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
>
>
>

 
Reply With Quote
 
=?Utf-8?B?S2VuIFR1Y2tlciBbTVZQXQ==?=
Guest
Posts: n/a
 
      22nd Mar 2005
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" wrote:

> Sorry for the duplicate post... I got an error on the original posting, and
> thought it was lost...
>
>
> "JohnR" <(E-Mail Removed)> wrote in message
> newsyN%d.12668$Ue6.1777@trndny04...
> > 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
> >
> >

>
>
>

 
Reply With Quote
 
Phill. W
Guest
Posts: n/a
 
      22nd Mar 2005
"JohnR" <(E-Mail Removed)> wrote in message
newsyN%d.12668$Ue6.1777@trndny04...
> 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.


 
Reply With Quote
 
JohnR
Guest
Posts: n/a
 
      22nd Mar 2005
I think I'll just have to go with an MSI install file. thanks for all your
help



"JohnR" <(E-Mail Removed)> wrote in message
newsyN%d.12668$Ue6.1777@trndny04...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Catching Errors with try catch gv Microsoft ADO .NET 4 27th Apr 2005 08:41 PM
how to catch errors from outlook helpwithXL Microsoft Excel Programming 1 14th Apr 2005 05:26 PM
How do you catch missing DLL errors? JohnR Microsoft VB .NET 0 22nd Mar 2005 04:54 AM
Re: How Can I Catch Framework Errors Natty Gur Microsoft ASP .NET 3 27th Aug 2003 01:01 AM
How Can I Catch Framework Errors MS News \(MS ILM\) Microsoft ASP .NET 3 25th Aug 2003 06:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:01 PM.