Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

CilTypeHashException in C# project when there is C++ project in deps
Marian
#1 Posted : Monday, February 19, 2024 3:09:23 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/13/2023(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
Hi, there is this odd issue where under some conditions a perfectly normal code element in a C# project causes CilTypeHashException when there is a C++ project in it's dependencies.

I know that C++ projects are not supported at all, but the C++ project builds fine. The code processing it just somehow messes up *something*.

For debugging purposes, I've minimized the repro solution (which fails 100% on my machine to analyze the C# project), but am unsure where to upload it.

The exception itself is this:

Quote:

NCrunch: If you are experiencing problems in getting this project to build, have a look at https://www.ncrunch.net/...ng_project-build-issues
NCrunch has encountered an internal error: System.Exception: nCrunch.Compiler.StaticManipulation.CilTypeHashException: Unable to hash type 'Repro.Class1' due to exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at nCrunch.Compiler.Cil.Symbols.Legacy.CilLegacySymbolsDataSource..ctor(Byte[] pdbFileContent, UInt32 entryPointToken)
at nCrunch.Compiler.Cil.CilAssembly.Load(FilePath assemblyFile, CilContext context)
at nCrunch.Compiler.Cil.CachedCilAssembly..ctor(FilePath assemblyFilePath, CilContext context, Boolean isInstrumentationTarget)
at nCrunch.Compiler.Cil.CilContext.LoadAssembly(FilePath assemblyFilePath)
at nCrunch.Compiler.Cil.CilSession.LoadAssembly(FilePath assemblyFilePath, Boolean isInstrumentationTarget)
at nCrunch.Compiler.Cil.CilSession.(String , String , UInt16 , UInt16 , UInt16 , UInt16 , String , String  )
at nCrunch.Compiler.Cil.CilSession.LoadAssembly(CilAssemblyReference assemblyReference)
at nCrunch.Compiler.Cil.CilSession.GetReferencedModule(CilModule referencingModule, UInt32 assemblyRefTableRowIndex)
at nCrunch.Compiler.Cil.AssemblyIdentity.CilAssemblyRefTable.GetAssemblyModuleByRowIndex(UInt32 tableIndex)
at nCrunch.Compiler.Cil.Types.CilTypeReference.(CilModule )
at nCrunch.Compiler.Cil.Types.CilTypeSignature.GetUnderlyingTypeForEnum()
at nCrunch.Compiler.Cil.CustomAttributes.CilAttributeArgument.get_SizeInBytes()
at nCrunch.Compiler.Cil.CustomAttributes.CilCustomAttributeValue.get_NamedArguments()
at nCrunch.Compiler.StaticManipulation.CilMethodHashGenerator.HashCustomAttribute(FNV64& hash, CilCustomAttribute customAttribute)
at nCrunch.Compiler.StaticManipulation.CilMethodHashGenerator.HashType(FNV64& hash, CilTypeDefinition type)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.ExtractClassMethodData(TestFrameworkDescription[] applicableTestFrameworks, IDictionary`2 codeFileIDsByForegroundFilePath, Boolean storeImpactHashes)
at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.ExtractClassMethodData(TestFrameworkDescription[] applicableTestFrameworks, IDictionary`2 codeFileIDsByForegroundFilePath, Boolean storeImpactHashes)
at nCrunch.Compiler.CilProcessingTasks.CilMethodHashingTask..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.()
at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.ProcessTasks(Int32 backgroundThreadsAllowed)
at nCrunch.Compiler.RemoteBuildRunner.(ComponentInstrumentationParameters , BuildOutput , IBackgroundTaskProcessor )
at nCrunch.Compiler.RemoteBuildRunner.PerformPostProcessingOfBuiltAssembly(ComponentInstrumentationParameters instrumentationParameters, BuildOutput output, IBackgroundTaskProcessor backgroundTaskProcessor)
at nCrunch.Core.BuildManagement.BuildEnvironment..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, IList`1 customEnvironmentVariables, IPlatformBuildExtender extender, Guid taskId, GridClientDescription clientDescription, Boolean extractCoverageReportStructure)


The C++ project in question contains nothing but a CLR enum with a single field and all the boilerplate.
That enum is used in an attribute on the C# project.

Best regards,
Marian
Remco
#2 Posted : Monday, February 19, 2024 11:23:56 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Marian,

Thanks for sharing this issue. This seems to be related to the structure of the PDB file. Could you submit your sample through the contact form? I'll take a look at this and see what I can do about getting it fixed.

As a potential workaround, could you try changing your project to use portable PDBs in your build settings?
Remco
#3 Posted : Tuesday, February 20, 2024 3:48:34 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Marian
#4 Posted : Tuesday, February 20, 2024 12:08:00 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/13/2023(UTC)
Posts: 4
Location: Germany

Was thanked: 1 time(s) in 1 post(s)
Thanks for the quick fix. It works! :)
1 user thanked Marian for this useful post.
Remco on 2/20/2024(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.052 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download