473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Handling missing dll exception

Hi,
I have an mini application with a dll named classlibrary1.

I used it via imports statement, but i tried something to catch a
custom msgbox error if the dll is not found or bad for the user.

I tried catch blabla as dllnotfoundexception with no help. Also try-
catch couldn't handle missing dll exception.

Could you define a sample code which calls a simple msgbox when a
button is pressed (if dll is missing)?

thanks
Dec 6 '07 #1
2 4009
kimiraikkonen wrote:
I have an mini application with a dll named classlibrary1.
I used it via imports statement,
.... (you referenced it first, but anyway) ...
but i tried something to catch a custom msgbox error if the dll
is not found or bad for the user.
Where are you trying to catch this error?

..Net code is loaded and linked method-by-method so, as soon as you try
to /call/ a method that uses your dll and it's not there, Boom! That
method fails to "appear", and you get a TypeLoadException (usually).

/If/ you can wrap a Try .. Catch around the call to /that/ routine, you
stand a chance:

Try
LoadCL1()
Catch ex As TypeLoadException
' Oops
End Try

Sub LoadCL1()

Dim olib as New classlibrary1()
. . .

End Sub

This /won't/ work ...

Sub LoadCL2()
Try
Dim olib as New classlibrary1()
. . .
Catch ex As TypeLoadException
' Oops
End Try
End Sub

.... because the /whole method/ gets loaded in one go and the referenced
libraries, etc. loaded. The code fails /before/ it even starts to
execute your "Try".
(BTW, this has caused me /great/ confusion in the past where the method
that's failing to load is the Elapsed event handler on a Timer!).

HTH,
Phill W.
Dec 6 '07 #2
On Dec 6, 7:12 pm, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
wrote:
kimiraikkonen wrote:
I have an mini application with a dll named classlibrary1.
I used it via imports statement,

... (you referenced it first, but anyway) ...
but i tried something to catch a custom msgbox error if the dll
is not found or bad for the user.

Where are you trying to catch this error?

.Net code is loaded and linked method-by-method so, as soon as you try
to /call/ a method that uses your dll and it's not there, Boom! That
method fails to "appear", and you get a TypeLoadException (usually).

/If/ you can wrap a Try .. Catch around the call to /that/ routine, you
stand a chance:

Try
LoadCL1()
Catch ex As TypeLoadException
' Oops
End Try

Sub LoadCL1()

Dim olib as New classlibrary1()
. . .

End Sub

This /won't/ work ...

Sub LoadCL2()
Try
Dim olib as New classlibrary1()
. . .
Catch ex As TypeLoadException
' Oops
End Try
End Sub

... because the /whole method/ gets loaded in one go and the referenced
libraries, etc. loaded. The code fails /before/ it even starts to
execute your "Try".
(BTW, this has caused me /great/ confusion in the past where the method
that's failing to load is the Elapsed event handler on a Timer!).

HTH,
Phill W.
I used catch inside button1.click sub. No luck. Then i tried inside
try-catch inside class library (dll) no luck again. Then tried "catch
xx as dllnotfoundexception" inside button1.click sub with no luck.

Could you simplify and sample with a more understanding way?

Very thanks.
Dec 6 '07 #3

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

Similar topics

2
by: Steph | last post by:
I am working on a Windows Forms App. I have attached a standard UnhandledExceptionEventHandler to the current domain to catch unexpected errors. In my application, when I trigger an unhandled...
13
by: R Reyes | last post by:
is there a way to avoid the validateRequest error page in my code behind file? i can't seem to find a way to handle the error w/o an error code or exception being thrown... i am NOT looking for...
4
by: Tad Marshall | last post by:
Hi, I'm having limited luck getting an ApplicationException to work right in my code. This is VB.NET, VS 2003, Windows XP SP2, .NET Framework 1.1. I thought it would be convenient to take...
1
by: Robin Tucker | last post by:
I keep reading about exception handling being preferable to "return codes". I would like to implement some kind of consistent use of exceptions in my code, but am finding it hard to come up with...
9
by: Gustaf | last post by:
I'm confused about structured error handling. The following piece of code is a simplification of a class library I'm working on. It works, and it does what I want, but I'm still not convinced that...
41
by: Jordan | last post by:
While writing some code, I realized I had never developed a consistent pattern for checking errors from a method. I have two styles I jump back and forth between, but I'm wondering which is...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
1
by: JRC903 | last post by:
Dear Folks: I am current working on a project involving trying to find the cause of some erratic behavior in an old Borland C++ 4.5 database application. Prehaps for obvious reason the orginal...
35
by: eliben | last post by:
Python provides a quite good and feature-complete exception handling mechanism for its programmers. This is good. But exceptions, like any complex construct, are difficult to use correctly,...
12
by: Fabiano Sidler | last post by:
Hi folks! I'm using gcc 4.2.3 and glibc6 2.7. I'm doing an exception handling implementation for a library. Although I assume to have it done properly, with a handler set up, it exits the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.