Programatically removing broken references.

L

Leighton.d

I have a module that executes when the database opens. It removes all
external references, then adds them in using the Guid's from the users
system. It errors when attempting to remove a broken reference. In this
case, it's the reference for "Microsoft ADO Ext. 2.8 for DLL and Security".
When it attempts to execute the "remove" code below, it displays the error
message "unable to open DLL module". I can manually remove the broken
reference from the "Tools/References" menu, but the program can't. If I
attempt to display the .name or the .isbroken property, I receive the same
error.

What am I missing? Thanks! Doug

For Each Ref In Application.References
If Ref.BuiltIn = False Then
Application.References.Remove Ref
End If
Next Ref
 
C

Chris Mills

I'm surprised no-one else has responded.

That's a completely invalid procedure.

It's like a surgeon doing open-heart surgery on HIMSELF. All very well until
he gave himself an anasthetic...

It's like trying to change a tire on the freeway whilst still moving at
(70mph)...

Not only are you (in effect) changing code whilst running same, you are trying
to change reference code which you have decided your app relies on, either
with other reference code or removing it. Everyone knows that reference code
can change between versions, not always for the better, so I'm left stunned
and wondering "WHAT THE HELL WERE YOU THINKING???"

On what other system, would you replace code WHILST RUNNING IT ?

Chris
 
L

Leighton.d

Gee... that was very helpful! If I'm trying to change a tire 'whilest'
still moving at 70mph, at least I'd still be moving forward! You post left
me standing in the same spot....

If a reference is broken, there's no harm in removing it, and replacing it
with a valid one.....
 
C

Chris Mills

If a reference is broken, there's no harm in removing it, and replacing it
with a valid one.....

Yes there is.

At the very least, your code will decompile whilst running it.

You can't do the same with an mde.

References is a DESIGN-TIME decision.

The proper procedure is to determine what references your app relies on, and
make them available if necessary. For this reason, try to reduce references to
a bare minimum in the first place. Use late binding perhaps.

Finally, as you rightly pointed out, problems may occur.

Here is some discussion of references which you may find interesting
http://www.trigeminal.com/usenet/usenet026.asp?1033

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top