BinaryFormatter.Deserialize “unable to find assembly” after ILMerge

前端 未结 10 1081
囚心锁ツ
囚心锁ツ 2020-12-14 20:53

I have a C# solution with a referenced dll (also C# with the same .Net version). When I build the solution and run the resulting exe, without merging the exe and the refere

10条回答
  •  春和景丽
    2020-12-14 21:30

    In case you merge assemblies into a existing one (for-example all DLLs to the EXE) you can use the solution proposed in this answer:

    // AssemblyInfo.cs for My.exe
    [assembly: TypeForwardedTo(typeof(SomeTypeFromMergedDLL))]
    

    This at least works for deserializing pre-merge. IL-Merge also still passes; even if you can't compile with a type-forward to a type of the same assembly...

    I have not tried, if serializing works post-merge yet. But I'll keep my answer updated.

提交回复
热议问题