C# CodeDom System.TypeLoadException XamMac2 Xamarin macOS
Posted
技术标签:
【中文标题】C# CodeDom System.TypeLoadException XamMac2 Xamarin macOS【英文标题】: 【发布时间】:2020-07-25 09:26:18 【问题描述】:我正在编写一个复杂的应用程序,该应用程序利用 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 之间的混合。
谢谢。
【问题讨论】:
【参考方案1】:确实如此。
打包在 System.dll 中的 System.CodeDom 程序集与构建项目必须引用的程序集不匹配。
通过同时设置 net461 的 netstandard2.0 来解决这个问题。
<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
</PropertyGroup>
像这样。
【讨论】:
看来你的问题已经解决了,记得把你的回复标记为答案,方便其他社区成员找到这个答案,谢谢。以上是关于C# CodeDom System.TypeLoadException XamMac2 Xamarin macOS的主要内容,如果未能解决你的问题,请参考以下文章
C# CodeDom System.TypeLoadException XamMac2 Xamarin macOS
CodeDom 将生成的 .cs 文件保存在哪里?我们可以将此位置更改为其他文件夹吗