简体   繁体   English

如何从应用程序域B访问应用程序域A中的静态类?

[英]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. 我遇到了一种情况,需要从应用程序域B访问我在应用程序域A中使用的单例静态类。我已经尝试过传递一个可序列化的对象,该对象具有将单例包装到应用程序域B的属性,但是只是重新创建Appdomain B中的单例。我真的不是很熟悉您在Appdomain之间进行通信的方式。 Is there some remoting library that actually ensures that the code is executed inside appdomain A while being called from appdomain B? 是否有一些远程处理库实际上可以确保在从应用程序域B调用时在应用程序域A中执行代码? 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. 我最终触发了一个从appdomain B到appdomain A的事件,并在appdomain A的事件处理程序中调用了单例。远程处理都是自动的。 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). 我遇到的几个问题是,我使用的远程代理对象默认在5分钟后过期(必须将过期设置为更长的时间),并且appdomain A中的类(事件处理程序必须从MarshalByRefObject继承)或否则,该代码实际上在appdomain B中执行(即使它在appdomain A类中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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