Working with AppDomain.AssemblyResolve event

前端 未结 2 1926
-上瘾入骨i
-上瘾入骨i 2020-11-28 13:41

I\'m trying to use AppDomain.AssemblyResolve event to handle exceptions while resolving Assemblies of some dll loaded at runtime (SerializationException for dyn

2条回答
  •  独厮守ぢ
    2020-11-28 14:26

    If you know list of assemblies that may contain type you are planning to deserialize it could be better to simply pre-load all assemblies before doing serialization.

    When AssemblyResolve event is fired you have no information about what type caused the load, but only assembly name. It is unclear why you would look up assembly by some particular type in this case.

    Note that if 2 assemblies happen to have the same identity (i.e. file name in non-strongly-signed case) and one is already loaded event will not fire when you expect even if type is not found in already loaded assembly.

    Link to the article for historical purposes: Resolving Assembly Loads.

提交回复
热议问题