CCDoc uncaught exception in unclear circumstances
-
15 Maret 2012 13:41
I found a strange situation in which CCDoc is failed with details:
CCDoc failed with uncaught exception: An item with the same key has already been added.
Stack trace: at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.Cci.MutableContracts.CodeContractAwareHostEnvironment.LoadUnitFrom(String location)
at Microsoft.Cci.MetadataHostEnvironment.Probe(String probeDir, AssemblyIdentity referencedAssembly)
at Microsoft.Cci.MetadataHostEnvironment.ProbeAssemblyReference(IUnit referringUnit, AssemblyIdentity referencedAssembly)
at Microsoft.Cci.MutableContracts.CodeContractAwareHostEnvironment.ProbeAssemblyReference(IUnit referringUnit, AssemblyIdentity referencedAssembly)
at Microsoft.Cci.MetadataReaderHost.ResolvingAssemblyReference(IUnit referringUnit, AssemblyIdentity referencedAssembly)
at Microsoft.Cci.PeReader.LookupAssembly(IModule referringModule, AssemblyIdentity unifiedAssemblyIdentity)
at Microsoft.Cci.MetadataReader.PEFileToObjectModel.ResolveModuleTypeRefReference(IMetadataReaderNamedTypeReference namedTypeReference)
at Microsoft.Cci.MetadataReader.ObjectModelImplementation.TypeRefReference.InitResolvedModuleType()
at Microsoft.Cci.MetadataReader.ObjectModelImplementation.TypeRefReference.Microsoft.Cci.ITypeReference.get_ResolvedType()
at Microsoft.Cci.MemberHelper.GetImplicitlyOverriddenBaseClassMethod(IMethodDefinition derivedClassMethod, ITypeDefinition baseClass)
at Microsoft.Cci.MemberHelper.GetImplicitlyOverriddenBaseClassMethod(IMethodDefinition derivedClassMethod, ITypeDefinition baseClass)
at Microsoft.Cci.MemberHelper.GetImplicitlyOverriddenBaseClassMethod(IMethodDefinition derivedClassMethod, ITypeDefinition baseClass)
at Microsoft.Cci.MemberHelper.GetImplicitlyOverriddenBaseClassMethod(IMethodDefinition derivedClassMethod)
at CCDoc.ContractVisitor.ContractPackager.PackageMethodContracts(IMethodDefinition method, Boolean isPure)
at CCDoc.ContractVisitor.Visit(IMethodDefinition methodDefinition)
at Microsoft.Cci.MetadataTraverser.Traverse(IMethodDefinition method)
at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 methods)
at Microsoft.Cci.MetadataTraverser.TraverseChildren(ITypeDefinition typeDefinition)
at Microsoft.Cci.MetadataTraverser.Traverse(INamespaceTypeDefinition namespaceTypeDefinition)
at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 namespaceMembers)
at Microsoft.Cci.MetadataTraverser.Traverse(INestedUnitNamespace nestedUnitNamespace)
at Microsoft.Cci.MetadataTraverser.Traverse(IEnumerable`1 namespaceMembers)
at Microsoft.Cci.MetadataTraverser.Traverse(IRootUnitNamespace rootUnitNamespace)
at Microsoft.Cci.MetadataTraverser.Traverse(IAssembly assembly)
at CCDoc.CCDoc.GetContracts(Options options, DocTracker docTracker)
at CCDoc.CCDoc.RealMain(String[] args)
at CCDoc.CCDoc.Main(String[] args)I get this error when override some method in class "TraceListenerData" from Microsoft Enterprise Library Logging Application Block, for example method "GetCreationExpression", or "ToString", but not "GetRegistrations". The sample code is:
namespace CCDocBug { using System; using System.Diagnostics; using System.Diagnostics.Contracts; using System.Linq.Expressions; using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration; /// <summary>Some class.</summary> public class Class1 : TraceListenerData { /// <summary>Some method.</summary> /// <returns>Some returns.</returns> protected override Expression<Func<TraceListener>> GetCreationExpression() { Contract.Ensures(Contract.Result<Expression<Func<TraceListener>>>() != null); return base.GetCreationExpression(); } } }Or you can download sample project here.
You should install Microsoft Enterprise Library to reproduce this error.
- Diedit oleh p.roman 15 Maret 2012 13:59
Semua Balasan
-
22 Maret 2012 18:09PemilikI will try to reproduce this. If you are able to create a small standalone repro please send it to me (in a zip file). I fixed a bug just last week that probably has to do with this issue, but I'd like to make sure.
Mike Barnett
-
23 Maret 2012 5:12
I don't know your email to send it to you so I just place it here.
It's a project with some required EntLib assemblies included. I hope it will work without installing EntLib.
PS: Sometimes you should rebuilt project twice to get this error.- Diedit oleh p.roman 23 Maret 2012 5:16
-
30 Maret 2012 8:10
I tried new release (1.4.50327) in new environment (Win8 CP 64bit with VS11 beta) and ccdoc works fine in this case, i.e. there is no error and xml doc file is correct. But in previous environment (Win7 64 bit SP1 with VS2010 SP1) problem still exists with new release of code contracts. I also tried to uninstall EntLib in old environment and this had no effect. Also notice that in some cases first build of sample project is successful, but xml doc file does not contains code contracts elements (<ensures> tag in this case). And only second rebuild causes the error.
Can I provide you any extra information that may help to fix this?
-
30 Maret 2012 16:00Pemilik
I"m still using Win7 with VS2010. Should your previous repro show me the problem if I run that?
Mike Barnett
-
30 Maret 2012 17:40Yes it should be (and I checked that it works without installing EntLib). But I'm not sure from what it depends: OS version, VS version or something else. That's why I'm asking about extra information (if you can't reproduce it by yourself).
-
31 Maret 2012 18:34Pemilik
Very bizarre! I believe I've fixed this, but just to make sure, can you please change your repro so that the reference to System.Configuration shows up in the Solution Explorer with a capital 'C'. I'm seeing it in the repro as "System.configuration" instead of "System.Configuration". This revealed a bug where I was doing string comparisons on file names using case senstivity. (I am going to sit in the corner now for an hour as penance.) You don't need to send me the repro again, just let me know if that fixes the problem for you.
In the meantime I've fixed it and the fix will appear in the next release.
I have no idea why this didn't show up in VS11, but I suppose your project there has the capital 'C'?
Sorry for the problem!
Mike Barnett
- Disarankan sebagai Jawaban oleh Mike BarnettMicrosoft Employee, Owner 31 Maret 2012 18:34
- Ditandai sebagai Jawaban oleh p.roman 02 April 2012 5:58
-
02 April 2012 5:58
Yes, changing to capital 'C' solves the problem.
Thanks.