且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

动态加载的Type的SerializationException

更新时间:2023-12-05 07:58:58

您可以将 AppDomain.AssemblyResolve 事件可在需要时加载程序集。每次运行时需要无法解析的程序集时,都会引发该事件。它为您提供了在抛出无法找到程序集异常之前提供程序集的最后机会。示例在我链接的页面上。

You could hook the AppDomain.AssemblyResolve event to load the assemblies as they are needed. the event is raised each time that the runtime needs an assembly that it cannot resolve. It gives you one last chance to provide the assembly before the "Unable to find assembly" exception is thrown. Examples are on the page that I linked.