事件未通过 AppDomain 触发
我在使用 AppDomains 时遇到了很多麻烦。我目前有一个包含相机控件的应用程序域,并且正在尝试将从该辅助应用程序域引发的事件(例如正在拍摄的照片)返回到主程序。一切似乎都设置正确(事件已注册,函数将跨域边界运行),但是当我尝试调用时,什么也没有发生。我能找到的关于这个主题的所有内容都涉及引发异常,而不是根本没有发生任何事情。
我不知道我能解释得比这更好多少,所以我制作了一个(非常简单的)图表,并且可以发布任何必要的代码。
http://a.imageshack.us/img832/8205/cameradiagram.png
在辅助 AppDomain 内的 OnPictureUpdated.Invoke(pic); 部分中触发断点,但没有任何内容(在 CameraContainer
内或在主应用程序中)被引发。我正在做调用事件时进行空检查,我只是没有将其放入图表中。
I am having a lot of trouble with AppDomains. I currently have an AppDomain containing camera controls, and am trying to have events raised from this secondary AppDomain (like a picture being taken) come back to the main program. Everything seems to be set up correctly (events are registered, functions will run across domain boundry) but when I try to invoke, nothing happens. Everything I can find on the subject involves exceptions being raised rather than just nothing happening at all.
I don't know how much better I can explain it than this, so I made a (very simplistic) diagram, and can post any code that is necessary.
http://a.imageshack.us/img832/8205/cameradiagram.png
A breakpoint fires in the OnPictureUpdated.Invoke(pic);
portion, inside the secondary AppDomain, but nothing (either inside CameraContainer
or in the main application is raised. I am doing a null check when invoking events, I just didn't put that in the diagram.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
+1表示在这个问题上的努力。
我相信这可能只是因为您的
CameraContainer
不是MarshalByRefObject
。由于它附加到事件,因此包含CameraManager
的AppDomain
实际上需要在引发事件时回调到主AppDomain
。+1 for the effort in the question.
I believe this may just be because your
CameraContainer
isn't aMarshalByRefObject
. Because it's attaching to the event, theAppDomain
containing theCameraManager
effectively needs to call back into the primaryAppDomain
when the event is raised.