Patrick
Patrick

Reputation: 2593

How to runtime link "plugin" reference dlls

I am afraid this is a too broad question. But I still have not a clue as to how start this job so even a clue would help since nothing came out from googling...

Whenever I link a reference I add it before building it. What I'd need is to be able to add whatever reference is added in a dir. That would allow me to put a dll in a dir and add it AT RUNTIME ONLY if that dll is present.

So say

and so on...

I call those dlls plugin since they are similar to plugins.

Thank you in advance for your help. Patrick

Upvotes: 0

Views: 66

Answers (1)

MarcoLaser
MarcoLaser

Reputation: 266

You could create a new AppDomain and set the appRelativeSearchPath to your plugin folder. Then you are able to load the additional assemblies using the Load method of your new AppDomain.

If you want to access classes from the new AppDomain in your applications main AppDomain you can instantiate them using the CreateInstanceAndUnwrap method of AppDomain. But the classes in your plugin assemblies have to inherit MarshalRefObject for this to work.

I hope this points you into the right direction.

Upvotes: 1

Related Questions