Link an external library at runtime in .NET

Is it possible for my application to monitor a folder that if we copy a DLL (library) in it, the application will pick it up and link it?

I did a similar thing in C++ back in the days but is it possible to dynamically link a library in .NET?

Thanks

Upvotes: 0

Views: 608

Answers (2)

plinth
plinth

Reputation: 49199

Absolutely. See this SO question or consider using the MEF.

Upvotes: 1

Brett Allen
Brett Allen

Reputation: 5507

Using reflection you could.

Poll the directory for added files, and then if you find one, load it using reflection and run some Main method inside it.

However you can't "unload" these DLLs unless they are loaded into seperate AppDomains.

Upvotes: 1

Related Questions