简体   繁体   中英

How can I access a static class in appdomain A from appdomain B?

I've run into a situation where a singleton static class I'm using in appdomain A needs to be accessed from appdomain B. I've already tried passing aa serializable object that has properties wrapping the singleton to appdomain B, but that just recreates the singleton in appdomain B. I'm really not all that familiar with the ways you can communicate between appdomains. Is there some remoting library that actually ensures that the code is executed inside appdomain A while being called from appdomain B? Can someone point me in the proper direction here?

Thanks!

I ended up firing an event from appdomain B to appdomain A, and calling the singleton in the event handler in appdomain A. The remoting stuff is all automatic. A couple problems I came across though were that the remoted proxy objects I was using expire after 5 minutes by default ( have to set the expiry to a longer time) and also the class in appdomain A where the event handler is must inherit from MarshalByRefObject or else the code is actually executed in appdomain B (even though its in the appdomain A class).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM