FxCop在命令行上抛出异常,但在GUI中没有?

时间:2011-09-15 14:09:28

标签: code-analysis fxcop fxcopcmd

我有一个FxCop 10.0项目可以通过FxCop GUI运行良好但是当我通过FxCopCmd命令行应用程序运行它(我想将其用作自动构建过程的一部分)时,它会生成以下异常 - 显然是试图加载程序集。

  <Exception Keyword="CA0001" Kind="Engine">
   <Type>System.InvalidOperationException</Type>
   <ExceptionMessage>Collection was modified; enumeration operation may not execute </ExceptionMessage>
   <StackTrace>   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at Microsoft.FxCop.Sdk.WeakAssemblyReference.FindMatchingReference(WeakAssemblyReference faRef, AssemblyReferenceCollection references, Hashtable cache)
   at Microsoft.FxCop.Sdk.WeakAssemblyReference.Initialize()
   at Microsoft.FxCop.Sdk.FrameworkAssemblies.GetFrameworkAssemblyReference(WeakAssemblyReference&amp; assemblyRef, String assemblyName)
   at Microsoft.FxCop.Sdk.FrameworkAssemblies.get_SystemCore()
   at Microsoft.FxCop.Sdk.FrameworkTypes.get_DynamicAttribute()
   at Microsoft.FxCop.Sdk.INodeWrappers.CCIParameterWrapper.get_DynamicTypes()
   at Microsoft.FxCop.Sdk.INodeWrappers.CCIParameterWrapper.get_Type()
   at Microsoft.FxCop.Sdk.NameProviders.NameProvider.WriteCommaSeparatedParameters(INodeCollection`1 parameters)
   at Microsoft.FxCop.Sdk.NameProviders.NameProvider.WriteMethodParameters(IMethodNode method)
   at Microsoft.FxCop.Sdk.NameProviders.NameProvider.WriteMethod(IMethodNode method)
   at Microsoft.FxCop.Sdk.NameProviders.CodeWriter.WriteCore(INode node)
   at Microsoft.FxCop.Sdk.NameProviders.NameProvider.WriteCore(INode node)
   at Microsoft.FxCop.Sdk.NameProviders.NameProvider.GetName(INode node)
   at Microsoft.FxCop.Engines.Introspection.Persistence.GetName(Node node, NameStyle style)
   at Microsoft.FxCop.Engines.Introspection.BaseVisitor.FindTargetMember(Member member, TargetMemberDictionary targets)
   at Microsoft.FxCop.Engines.Introspection.LoadVisitor.FindTargetMember(Member member, TargetMemberDictionary targets)
   at Microsoft.FxCop.Engines.Introspection.BaseVisitor.VisitMembers(MemberCollection members, TargetMemberDictionary targets, Boolean visitNestedTypes)
   at Microsoft.FxCop.Engines.Introspection.BaseVisitor.VisitType(TypeNode type, TargetType target)
   at Microsoft.FxCop.Engines.Introspection.LoadVisitor.VisitType(TypeNode type, TargetType target)
   at Microsoft.FxCop.Engines.Introspection.BaseVisitor.VisitTypes(TypeNodeCollection types, TargetNamespaceDictionary targets)
   at Microsoft.FxCop.Engines.Introspection.LoadVisitor.VisitModule(ModuleNode module, TargetModule target)
   at Microsoft.FxCop.Engines.Introspection.BaseVisitor.VisitAssembly(AssemblyNode assembly, TargetFile target)
   at Microsoft.FxCop.Engines.Introspection.LoadVisitor.VisitAssembly(AssemblyNode assembly, TargetFile target)
   at Microsoft.FxCop.Engines.Introspection.LoadVisitor.Load(TargetFile target, Boolean buildTree, Boolean queueItems, AssemblyNode loadedAssembly)
   at Microsoft.FxCop.Engines.Introspection.LoadVisitor.LoadAssemblies(Queue queue, ExceptionCollection exceptions)</StackTrace>
  </Exception>

我在谷歌上找不到任何有意思的东西,所以有没有人有任何想法可能导致这个?

2 个答案:

答案 0 :(得分:1)

您是否在UI和命令行运行中使用相同的.fxcop项目文件?如果没有,您是否可以在FxCop UI设置中禁用多线程加载?

如果您不确定,最好的办法是尝试使用.fxcop项目文件,并禁用多线程加载命令行运行。

答案 1 :(得分:1)

这是因为尝试在10.0文件上运行FxCop 1.36。我们的单元测试代码试图在两个不同的文件夹中找到FxCop,我只更新了其中一个:(