相关疑难解决方法(0)

AppDomain.CurrentDomain.GetAssemblies fails with ReflectionTypeLoadException

During unittesting I have run into a problem with the following code that asks for all the loaded assemblies:

var res = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(x => x.GetTypes())
.ToList();
Run Code Online (Sandbox Code Playgroud)

this code fails with a ReflectionTypeLoadException which has inner exceptions of the pattern

Could not load type Microsoft.Xml.Serialization.GeneratedAssembly.FOO

where FOO are some specific classes also coded by us.

The problem arises when running unittests prior to the above which creates XML documents using the XDocument class.

我可能不会想要加载这些代码生成的类(我猜测Microsoft.Xml.Serialization.GeneratedAssembly.*是生成的代码.)我只想了解什么是错误的.

c# reflection

6
推荐指数
1
解决办法
2152
查看次数

标签 统计

c# ×1

reflection ×1