none
AppDomains RRS feed

  • Question

  • Hello All,

    I've got Windows Services that uses class libraries as plugins. For some reason sometimes I've got to update some plugin on the fly. So i'm loading new assemblies into new appdomains. And the problem is how can I access to some classes within default appdomain in my new one or how can I pass some classes instances into new appdomain? The reason is I've got a bunch of variables (connectionstrings, etc..) used by assemblies and I don't want to load them everytime I load some new assembly. Those are being loaded once at the service startup ...

    Wednesday, November 4, 2015 4:07 PM

Answers

  • Hi Seba...,

    An AppDomain provides a layer of isolation within a process. It is a dynamic concept.

    >>how can I access to some classes within default appdomain in my new one

    I suggest you put the classes in a new library. Then use it in other assemblies.

    >>how can I pass some classes instances into new appdomain?

    You need to get the reference of primary AppDomain in the new AppDomain. You could use AppDomainManager to do it. Link below is for your reference
    http://stackoverflow.com/questions/7120866/how-to-get-parent-appdomain
    Then use CreateInstance method to get the instance.

    In addition, based on the big cost of marshalling across the AppDomain boundaries.  I suggest you using Memory-Mapped Files to share data for appdomains.

    Best Regards,
    Jerry

    Friday, November 6, 2015 3:08 AM

All replies

  • maybe this?
    Wednesday, November 4, 2015 5:46 PM
  • Hi Seba...,

    An AppDomain provides a layer of isolation within a process. It is a dynamic concept.

    >>how can I access to some classes within default appdomain in my new one

    I suggest you put the classes in a new library. Then use it in other assemblies.

    >>how can I pass some classes instances into new appdomain?

    You need to get the reference of primary AppDomain in the new AppDomain. You could use AppDomainManager to do it. Link below is for your reference
    http://stackoverflow.com/questions/7120866/how-to-get-parent-appdomain
    Then use CreateInstance method to get the instance.

    In addition, based on the big cost of marshalling across the AppDomain boundaries.  I suggest you using Memory-Mapped Files to share data for appdomains.

    Best Regards,
    Jerry

    Friday, November 6, 2015 3:08 AM