定位
NullReferenceException
在许多代码中,您必须将其分解,以查看返回空值的内容。在你的代码中,我只看到一个可能的地方。试试这个:
var abstractViewModelType = typeof (AbstractViewModel);
var baseAssembly = Assembly.GetAssembly(abstractViewModelType);
var modelTypes = baseAssembly.GetTypes()
.Where(assemblyType => (assemblyType.Namespace != null // Problem if null
&& assemblyType.Namespace.EndsWith("Models")
&& assemblyType.Name != "AbstractViewModel"))
.Select(assemblyType => assemblyType);
foreach(var modelType in modelTypes)
{
//Assert some things
}