Advertisement Jump to content
Sign in to follow this  

[.net] Dynamic dll loading

This topic is 4930 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm no expert on assemblies, so please bare with me. My idea is to have a plugin folder which will contain dll files, finding them and listing them is easy but, how exactly would i use "Assembly" to load dlls etc runtime? Most of the examples i've used have had the dlls added to the .exe file's workspace through "Add reference". Each dll would be a separate program running under it's own app domain in it's own thread. I'd like some help on how i should go about doing what i just described.

Share this post

Link to post
Share on other sites
Look around in this forum. Dynamic DLL loading has been discussed several times here.

To create the DLL in a separate AppDomain do this:

- Create a domain with AppDomain.Create
- Write a class that provides code to load an Assembly (e.g. by calling Assembly.Load) and start the thread. The class must derive from MarshalByRefObject, otherwise the code won't be called in the AppDomain that created the object (see below).
- Create an object of this class in the new AppDomain (AppDomain.CreateInstance)
- Invoke the method mentioned above on that object.

This way the dynamically loaded DLL won't bleed into the original domain.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!