I am working on an add-on component that needs to play nice with other similar add-ons. There is a 3rd party component that decided to implement the functionality a little differently than the default.
What I am trying to do is call an overload of a method that only the 3rd party component has, like this:
Select Case True
Case TypeOf provider Is 3rdParty.Provider
result = DirectCast(provider, 3rdParty.Provider).GetNames(method, True)
Case Else
result = provider.GetNames(method)
End Select
Unfortunately, the DLL that contains 3rdParty.Provider is optional, so this code will give compile errors if it is not present. How can I accomplish the same thing but make it safe to run whether the 3rdParty.Provider.dll is present or not?
After some trial and error and going through several MSDN docs and forum posts, I was able to piece together the following solution:
I tested removing the 3rd party DLL reference from my project and this works without a hitch and calls the default GetNames in that case without any exceptions or compile errors.