Jump to content
  • Advertisement
Sign in to follow this  
Cybrosys

[.net] Dynamic dll loading

This topic is 4862 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
Advertisement
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.

Regards,
Andre

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!