如何修复 'System.TypeLoadException' 类型的异常

How to fix An exception of type 'System.TypeLoadException'

我正在开发通用 Windows 平台 (UWP 10) C# 应用程序,我尝试在其中实现 AIML 聊天机器人,但我发现此异常存在问题:

An exception of type 'System.TypeLoadException' occurred in AIMLbot.dll but was not handled in user code

Additional information: Could not load type 'System.Xml.XmlDocument' from assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

有什么我可以做的吗,我正在考虑更改 Default.rd.xml !

从异常信息可以看出,AIMLbot.dll无法加载System.Xml。

An exception of type 'System.TypeLoadException' occurred in AIMLbot.dll but was not handled in user code

Additional information: Could not load type 'System.Xml.XmlDocument' from assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

您需要验证 AIMLbot.dll 的目标框架是否可以支持 System.Xml Version 2.0.5.0。您可能已经降级了目标框架,或者如果您正在通过

加载程序集
Assembly xmlAssembly = Assembly.Load("System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e");

您需要检查版本。