How can I tell programatically if a Reference is missing

donphillipe
10-08-2009, 02:39 PM
Let's suppose I create a project and someone deletes the reference or there ends up being no file that the reference points to on the system where the project is trying to run and I want to say "Hey dummy, you need this XYZ file to run this". Otherwise all this cryptic (to the user) errors come up; it would be nice to actually have the program state what is wrong.

Short story:

How can I tell what REFERENCES have been added or not, i.e.

Programatically, how can I find out if this line exists.

Reference=*\G{420B2830-E718-11CF-893D-00A0C9054228}#1.0#0#..\..\WINDOWS\SYSTEM32\scrrun.dll#Microsoft Scripting Runtime

Now that I think about it, I guess I could read back to my own VBP file but that seems a little primitive.

Iceplug
10-08-2009, 07:21 PM
As far as I know, the references are added to the program before any line in the program runs... because my old DirectX programs raised the error before showing the only form which doesn't use any DirectX references.

jantje
10-16-2009, 04:29 AM
As far as I know, the references are added to the program before any line in the program runs... because my old DirectX programs raised the error before showing the only form which doesn't use any DirectX references.
Only the interface definition is compiled into the program.
Creating an instance of an unregistered object raises an error.

For instance you can add a reference to a dll and do this in code

Dim myTest as SomeObject

This wont error in the executable, even when you unregister the control and delete it from your harddrive.
It's until you do

Set myTest = new SomeObject
'or
Dim myTest as new SomeObject

Then it will error.

@TS
Whilst defensive programming is good, this is something you shouldn't worry about too much, IMHO.
If you supply your application with a decent installer, then this will be no issue.
If the end user decides to wreck his/her system, for whatever reason, then that's not really your problem.
When there are errors popping up like 'activex can't create object' you know the installer should be run again.

Messages like "you need to have this installed" are only valid if you use late binding.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum