由于缺少程序集而导致 MEF 中出现反序列化错误
我用的是MEF。 我序列化依赖于加载的程序集之一的对象之一。
现在,当我尝试反序列化该对象时,它会抛出“无法找到程序集”异常。 MEF 在另一个类中反序列化之前加载程序集(我假设其范围是应用程序范围,它将它们加载到公共属性中)。
既然 MEF 已经将这些程序集加载到应用程序域,为什么 BinaryFormatter.Deserialize()
找不到它们?
我可以使用 System.Reflection.Assembly.Load,但是使用 MEF 有什么意义呢? MEF对此有特别支持吗?
I'm using MEF. I serialize one of the objects which relies on one of the loaded assemblies.
Now when I try to deserialize this object it throws "Unable to find assembly" exception. MEF loads the assemblies before this deserialization in another class (I assume that the scope of this is application wide, it loads them into a public property).
Since MEF has already loaded these assemblies to the application domain why BinaryFormatter.Deserialize()
can't find them?
I can use System.Reflection.Assembly.Load
but then what's the point of using MEF? Has MEF got special support for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
现在 程序集探测 成功了,尽管我仍然没有确定这是否是最佳实践,因为我仍然在这里绕过 MEF,这不好。
我仍在测试是否有副作用或类似的情况。 这些的明显缺点是我需要加载相同的 DLL 两次
For now assembly probing did the trick, although I'm still not sure if this is the best practices because I still bypasses MEF in here which is no good.
I'm still testing though to see if there is a side effect or something like that. Obvious disadvantage of these that I need to load same DLLs twice