My Application is built to a scan MS Access database in VB.NET.
When the Access application is distributed to end users, they may have different versions of COM components. Is it possible to Add/Remove references programmatically to resolve broken references due to differing versions?
Please share me code or link for reference.
Here is some sample code:
Create Reference from File
Delete Reference
Reference Exists
From: http://wiki.lessthandot.com/index.php/Add,_Remove,_Check_References
You may also wish to read http://www.mvps.org/access/modules/mdl0022.htm
The best solution is to limit references in your Access MDB to internal Access components. This would be the Access reference, the VBA reference, and the DAO reference. All other outside libraries should be used through late binding. If you're using the File System Object, for instance, instead of this (with a reference to the Windows Script Host Object Model):
you would remove the reference and convert it to this:
If you're concerned about the performance hit of initializing the FSO each time you use it, you can cache a reference to it. I usually use a static variable inside a function to return an object like this:
Now, you might want to get fancy and also be able to tear down the instantiated object, in which case you'd do something like this:
In any event, the whole point is that late binding resolves the location of the outside libraries at runtime and thus won't break, except if the outside library is not installed or not properly registered. With late binding, you can trap for both of those conditions, but with early binding, your whole Access app simply breaks.