473,804 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to catch missing DLL errors

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 "Applicatio n 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 GlobalLibraryVa rs = getGlobalVarsOb ject()
'GlobalLibraryV ars 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
Nov 21 '05 #1
5 4331
Sorry for the duplicate post... I got an error on the original posting, and
thought it was lost...
"JohnR" <Jo******@hotma il.com> wrote in message
news:DyN%d.1266 8$Ue6.1777@trnd ny04...
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 "Applicatio n 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 GlobalLibraryVa rs = getGlobalVarsOb ject()
'GlobalLibraryV ars 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

Nov 21 '05 #2
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 "Applicatio n 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 GlobalLibraryVa rs = getGlobalVarsOb ject()
'GlobalLibraryV ars 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

Nov 21 '05 #3
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" <Jo******@hotma il.com> wrote in message
news:DyN%d.1266 8$Ue6.1777@trnd ny04...
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 "Applicatio n 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 GlobalLibraryVa rs = getGlobalVarsOb ject()
'GlobalLibraryV ars 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


Nov 21 '05 #4
"JohnR" <Jo******@hotma il.com> wrote in message
news:DyN%d.1266 8$Ue6.1777@trnd ny04...
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.
Nov 21 '05 #5
I think I'll just have to go with an MSI install file. thanks for all your
help

"JohnR" <Jo******@hotma il.com> wrote in message
news:DyN%d.1266 8$Ue6.1777@trnd ny04...
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 "Applicatio n 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 GlobalLibraryVa rs = getGlobalVarsOb ject()
'GlobalLibraryV ars 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

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
6897
by: kaeli | last post by:
Hey all, I'd like to start using the try/catch construct in some scripts. Older browsers don't support this. What's the best way to test for support for this construct so it doesn't kill non-supporting browsers? TIA -- --
9
2359
by: Joe Rigley | last post by:
Hello, As a .NET newbie I'd appreciate some advice... I've been tasked with writing a small app (in VB .NET) that takes some data from our HR system, does some format modifications, and loads that into Active Directory. For error handling of this app, I was considering having the app process each employee one at a time. If an error occurs, I was thinking that the system would handle the error with a Try/Catch, send the error details...
8
7822
by: Daniel Portal | last post by:
Hi there, I'm in 3-tier project and I'm thinking about having Try / Catch statements in each method, just in case you know! If the case is that I don't have a special treatment for the error in some method I would Cath the error and Re-Throw it! The question is: what are the issues of this approach? Would I have performance problems cus of my catches? What does MS recommends in such a situation??
11
1494
by: Tamas Demjen | last post by:
I was shocked to learn that VC++ 2005 Beta 2 can't catch Access Violation exceptions in unmanaged code. To reproduce this, I created a minimal Win32 console application: #include "stdafx.h" int _tmain(int argc, _TCHAR* argv) { int* p = 0;
0
1205
by: JohnR | last post by:
Hi all.. my application uses a custom dll which should be in the same directory as the exe file. If the dll file is missing the application immediately aborts with a "Application has generated an exception that could not be handled" exception. I would like to catch the error and display a meaningful message. I tried TRY CATCH in the SUB Main(), I tried ON ERROR in the SUB Main(), I also tried to test for a fileinfo.exists on the dll...
32
6132
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I understand Finally runs whether an error was caught or not, I haven't found a use for finally yet.
1
2013
by: aemado | last post by:
I am trying to read in several lines, each should have exactly 5 pieces of data. I am using try/catch/throw to determine if the data is in the correct format, and trying to use iss to separate the parts. However, this is my first time using both, and I am pretty certain that I am missing something obvious. Firstly, by debugging, I found that the first piece of data is being checked in the second case, giving me errors. I believe I may need to...
5
14328
by: kellygreer1 | last post by:
I think I'm not quite understanding something about error handling in PHP5. I have written some PHP code to index the contents of C drive on a Windows machine. When it gets to certain special folders (fake folders) it runs into errors. Directories it can not read from. I have tried wrapping the code in a Try / Catch and the error still comes through. What am I missing? <?php // Here is the code: function indexFiles($path, $handle) {
3
1691
!NoItAll
by: !NoItAll | last post by:
OK, I'd like to know the difference between the following two blocks of code: Block A Try Something Catch Process Errors End Try
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.