首先,只有当我针对程序集运行db4oTool时才会发生此问题,该程序集将作为目标,目标是正常的.Net类库。
问题:我以post build事件的形式运行以下命令:
Db4oTool.exe -tp -vv -debug -collections -by属性:doNotDb4Oforcance -not $(TargetPath)
这将导致打印到输出窗口的以下错误:(完整日志这里)
输入方法‘Ats.Loto.Model.EnergyTagExtensions::GetNextTagNumber(System.Collections.Generic.IList
1<Ats.Loto.Model.EnergyTag>,Ats.Loto.Model.EnergyType)' System.NullReferenceException: Object reference not set to an instance of an object. at Db4oTool.TA.TACollectionsStep.<TAEnabledCollectionInstantiations>b__4(Instruction candidate) at Db4oTool.Core.InstrumentationUtil.<Where>d__0.MoveNext() at Db4oTool.TA.TACollectionsStep.InstrumentCollectionInstantiation(MethodDefinition methodDefinition) at Db4oTool.TA.TACollectionsStep.Process(MethodDefinition method) at Db4oTool.TA.TAInstrumentation.ProcessMethod(MethodDefinition method) at Db4oTool.Core.AbstractAssemblyInstrumentation.ProcessMethods(IEnumerable methods) at Db4oTool.Core.AbstractAssemblyInstrumentation.ProcessTypes(IEnumerable1类型,谓词1 filter, Action1动作(在Db4oTool.Core.AbstractAssemblyInstrumentation.Run(InstrumentationContext上下文中)在Db4oTool.Core.InstrumentationPipeline.Run() at Db4oTool.Core.InstrumentationPipeline.Run() at Db4oTool.Program.RunPipeline(ProgramOptions options) at Db4oTool.Program.Run(ProgramOptions options) at Db4oTool.Program.Main(String[] args)
如果我删除-collections属性,它就会工作。我尝试将"EnergyTagExtensions“类排除在
-by-attribute:DoNotDb4OEnhance -not
开关,但它要么没有效果,要么我做错了。
下面是我认为是基于日志导致db4otool不开心的类。
[DoNotDb4OEnhance]
public static class EnergyTagExtensions
{
public static int GetNextTagNumber(this IList<EnergyTag> source, EnergyType activeEnergyType)
{
if (source.Count == 0)
return 1;
var concernedTags =
source.Where(c => c.TagId != null && c.TagId.StartsWith(activeEnergyType.Prefix)).OrderBy(
c => c.TagIndex).ToList();
if (!concernedTags.Any())
return 1;
return (concernedTags.Max(c => c.TagIndex) + 1);
}
}有什么办法让这件事起作用吗?提前感谢您的任何见解。
发布于 2012-01-25 11:19:07
对于Db4oTool不“尊重”过滤器,问题是您需要输入属性的完全限定名。
还请注意,不能从属性名称中省略属性(我假设您遵循了DoNotDb4OEnhanceAttribute)的.Net最佳实践,并将属性命名为
我只是填写了一个问题来改进Db4oTool文档。
关于NullReferenceException,我会尝试复制,但是如果我不能,你能私下寄给我一个小的示例程序集来复制它吗?
编辑-2012年3月01/2012
我查看了Monodroid文档,发现Func确实是在mscorlib中定义的(在Monodroid上),所以Db4oTool可能在错误的程序集中查找类型。
https://stackoverflow.com/questions/8995129
复制相似问题