Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   How to handle "*.dll" not found ? (http://www.go4expert.com/forums/handle-dll-t17338/)

SaswatPadhi 5May2009 09:42

How to handle "*.dll" not found ?
Hi all,

I don't know if this has been asked before, but I could not find anything relevant by searching. So, decided to start new thread.

I am writing a VB.NET program that includes a COM component, which (i guess) might not be available on all target machines. As the component just adds bells and whistles to my app, and does not have anything to do with the main purpose, I wanted to find a way to continue execution of the app on the systems without the dll.

The problem is, the app crashes with a "*.dll" not found error.

I want something that would fit this format :


' Pseudo-code

If DllFound() Then              ' DllFound checks the existence of the Dll
    TextBox1.Text = Msg
End If

Please help me figure out the DllFound() function.

Thanx in advance.

SaswatPadhi 5May2009 09:49

Re: How to handle "*.dll" not found ?
Sorry, my mistake -- I posted the thread twice !
MODS, please delete this one.

People, please reply on the other thread.

shabbir 5May2009 10:09

Re: How to handle "*.dll" not found ?
Deleted the other one.

For the Dll to exist or not just check using the File Operations methods

SaswatPadhi 5May2009 15:15

Re: How to handle "*.dll" not found ?
Sorry, if you could not follow; but that was not what i wanted !

I wanted the app to execute normally even if the dll is not found. If a dll component is not present on the target system, the app won't start at all. It would report a "dll not found error !".

For the example i've given above consider "XVoice.dll" that converts text to speech. If XVoice.dll is missing, the app would fail to start on target system. What's the use of checking dll's existence then ???

shabbir 5May2009 16:39

Re: How to handle "*.dll" not found ?
File.exists should do it for you

SaswatPadhi 5May2009 18:13

Re: How to handle "*.dll" not found ?
Could you just make it clear with an example ?
I still don't think that would work 'cuz I've already tried that.

The program would execute the statement File.Exists, if it's able to run !
The program would exit with "dll not found" error before executing *ANY* instruction !

Please make yourself clearer.

shabbir 5May2009 19:59

Re: How to handle "*.dll" not found ?
if(File.Exists("/path/to/your/dll/file") == true)
We know the file exists

Read this

SaswatPadhi 5May2009 20:46

Re: How to handle "*.dll" not found ?
Hey, that is obvious and i know that. And that's applicable not only to dlls, but also to all files.
Why do you think I started this thread then?

Just try making a new VB.NET project and add a COM component, let's say the "FoxItReader.dll" file. Now declare an object of that type say : "Dim XFox As FOXITREADEROCXLib". Now put your dll check in form load event and output in a text-box if the dll is available or not.

Run on a system *without* the specified dll and see if the app informs the dll's absence correctly. I tried to make this.. but the app crashes with dll not found error instead of running!

If your check works, please attach the source-code and I would be really grateful to you for the time and energy you've spent for me. Thanx in advance .. :)

shabbir 5May2009 21:22

Re: How to handle "*.dll" not found ?
Now what you are trying to do is create an object of a class which does not exist on the PC and so it should not be done the way you are doing it. The way it should be done is as follows.

Create your own wrapper dll for FoxItReader.dll and I would call it MyFoxItReader.dll which does all the needed object initialization and variable declaration.
Then in your app you do the checking if you have the needed DLL extension
If yes then you load your own dll ( MyFoxItReader.dll )

I hope you got what I meant.

SaswatPadhi 5May2009 21:31

Re: How to handle "*.dll" not found ?
Many thanx shabbir :)

All times are GMT +5.5. The time now is 00:34.