简体   繁体   English

如何将Unity IoC从一个AppDomain传递到另一个

[英]How to pass Unity IoC from one AppDomain to another

I try to pass a Unity container instance to an AppDomain but i get a SerialisationException for the UnityContainer . 我尝试将Unity容器实例传递给AppDomain,但是我收到SerialisationExceptionUnityContainer

Is there any solution to past multiple objects from host to an plugin/AppDomain without to past every single element in the constructor of the AppDomain. 是否有解决方案,可以将主机中的多个对象过去到插件/ AppDomain中,而不必将AppDomain构造函数中的每个单个元素都过去。

Greetings 问候

You can't -and shouldn't- pass your DI container from App Domain to app domain. 您不能(也不应)将您的DI容器从App Domain传递到App Domain。 That doesn't make sense, since the DI container would resolve instances that are defined, known, and cached within that app domain and even when the container would be moved across AppDomains, you would have to make sure that all your registrations are movable as well. 这没有任何意义,因为DI容器将解析在该应用程序域内定义,已知和缓存的实例,即使当该容器在AppDomain之间移动时,您也必须确保所有注册都可以移动好。

Instead you should either make sure that everything is running in the same AppDomain, or create one container per App Domain. 相反,您应该确保所有内容都在同一AppDomain中运行,或者应为每个App Domain创建一个容器。

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

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