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.