I have the full path to a dll, but not a reference, where I need to instantiate an object that implements an interface that I’ve defined.
I do have control over the other dll, so I am able to do things like stick a static function in the dll that returns the object I need. I’m just not sure how to call that function, or even if I’m approaching this right.
I have the full path to a dll, but not a reference, where I
Share
You’ll need to manually load the assembly, then use reflection to find and execute the method you’re interested in. Here’s an article.
The interesting calls/statements in that article are:
Calling
Assembly.Load()to have the runtime load the assembly into the AppDomain (making it’s members callable).Searching the
Types contained in the assemblyBuilding
MethodInfoandConstructorInfoobjects, which are the reflection components used to call a method or instantiate an instance, respectivelyCalling
.Invoke()on theMethodInfoorConstructorInfo.Invoke()is essentially telling Reflection to execute the corresponding method.