“Could not load file or assembly 'System.Core, Version=2.0.5.0,…” exception when loading Portable Class Library dynamically

前端 未结 3 1615
北海茫月
北海茫月 2021-01-04 08:00

First of all I need to emphasize that this is slightly different question than the one in this thread. Additionally, installing KB2468871 doesn\'t help.

I tried to s

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 08:29

    I had the same problem and ended up with the following solution: invoke the following code before dynamically loading the PCL assembly.

    Assembly.Load("System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes");
    Assembly.Load("System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes");
    

    If any other dependency is missing when you load your PCL assembly, you just need to add a line to code above. For some strange and ununderstandable reason, it works.

提交回复
热议问题