C# CodeDom System.TypeLoadException XamMac2 Xamarin macOS



我正在编写一个复杂的应用程序,该应用程序使用CodeDom实例化具有反射的对象。然而,它混合在netstandard2.0(中间的包装器也支持net461(和net461项目之间。

正如我所读到的,很有可能参考以前版本的框架,这种情况如下:

{System.TypeLoadException: Could not resolve type with token 01000067 from typeref (expected class 'System.CodeDom.Compiler.CompilerParameters' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')  

忽略为Xamarin Mac可执行文件加载到内存中的系统引用。

不适合的是寻找可能被Xamarin系统程序集覆盖的系统程序集的代码。

你知道有什么解决办法吗?除了将剩下的一组项目完全迁移到netstandard2.0和net461之间的混合之外。

谢谢。

确实如此。

封装在System.dll中的System.CodeDom程序集与要生成的项目必须引用的程序集不匹配。

这是通过将两个net461都设置为netstandard2.0来解决的。

<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
</PropertyGroup>

像这样。

最新更新