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

Notification

Icon
Error

Unknown constant type build failure
berinder
#1 Posted : Friday, February 8, 2013 10:58:29 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/8/2013(UTC)
Posts: 6
Location: Sweden

Thanks: 2 times
I get a build error that says
(0)#1: CA0001 : Unknown constant type.

Because of NDA i can't post the code, and before i start sitting and "cutting out the pieces" i wanted to see if anyone knew what may be the reason.

It builds fine outside of NCrunch, ofcourse.
Remco
#2 Posted : Saturday, February 9, 2013 10:57:22 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

Thanks for posting!

Does your build run correctly if you turn off the 'Instrument output assembly' setting for the project showing this error?

Also - can you confirm which version of NCrunch you are running?


Cheers,

Remco
berinder
#3 Posted : Monday, February 11, 2013 6:49:50 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/8/2013(UTC)
Posts: 6
Location: Sweden

Thanks: 2 times
No, it didn't help to turn of "instrument output assembly".

I'm running the evaluation of 1.44.0.11 for VS2010.
Remco
#4 Posted : Monday, February 11, 2013 9:06:45 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks, that narrows it down to the build itself (rather than NCrunch manipulation).

As it can be quite tough to troubleshoot an issue like this without source code to recreate it, I hope you don't mind me bombarding you with a few questions ...

- Which language are you working in? I.e. VB.NET, C#, etc
- Are you using FxCop?
- Do you have anything in your build that could be considered unusual (i.e. build customisations, 3rd party static manipulation frameworks, etc)
- Do you use pre/post build events for critical steps in your build?
- Have you had a look through the troubleshooting builds guide in the documentation? There are a few steps in here that may help give some useful information
- Does your NDA allow you to submit a bug report? I may be able to examine the build trace for clues as to what is causing the issue


Cheers,

Remco
berinder
#5 Posted : Tuesday, February 12, 2013 6:40:12 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/8/2013(UTC)
Posts: 6
Location: Sweden

Thanks: 2 times
Hello,

I'm very grateful for the help and not minding at all!

It's a MVC3 C# Application.

I'm using the Code Analyze tool from Visual Studio 2010 Premium, but no stand alone FxCop.

No odd build steps, nothing i do react on... I admit that i don't know everything that is in the solution though. But the failing project in the solution have nothing odd when i check.

Checked the troubleshooting builds link, manage to solve another problem (or, atleast remove the offending code) but this one still remains.

Bug Report sent with title "Build fails with "Unknown constant type""

Thanks for your help! It's very appreciated. Managed to test NCrunch on another project and both me and my pairing partner loved it, now we must get it to work on this project to be able to buy it.

Best Regards
Leif

Remco
#6 Posted : Tuesday, February 12, 2013 6:53:34 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks Leif!

I've had a quick skim over the bug report, although unfortunately the error message wasn't shown in the log. Often with large solutions, the errors can 'run off the top' of the rolling log (which has a limited size). There may, however, be a better way to get more information about what is happening in the build.

Try setting your 'Log Verbosity' global configuration setting to 'Detailed', then examine the output text shown against the failed build in NCrunch's Processing Queue Window. This will give a full detailed dump of all the MSBuild output which may give some clue as to which target is causing the problem.

Another very useful thing to try is to see if you can make the project build using a command-line MSBuild invocation from the NCrunch workspace that has been created for it. In order to do this, just right click the failed project build in the Tests Window, then choose 'Browse to workspace'. Open up a command prompt at the location of the .csproj file, then try running msbuild.exe against this file. You may need to set up your Path environment variable to put to MSBuild (or reference it under your framework SDK directory from the command line). This is a very useful test, as it can tell us whether the build error is being caused by NCrunch's workspacing or whether it is something environmental inside NCrunch's build process.

If you haven't already, try also turning off any code analysis steps in the project's configuration in Visual Studio. These steps do add complexity to the build process and it's worth eliminating them to be sure they aren't somehow causing the problem.

With an ambiguous message such as this, I often find the best approach is the process of elimination to narrow down exactly which step in the build is conflicting with NCrunch. It's the first time I remember having seen this message though, which suggests there is something quite interesting about this project. Let me know how the above steps go, and if the source of the problem doesn't appear, I'll try to suggest a few things to narrow it down further.


Cheers,

Remco
1 user thanked Remco for this useful post.
berinder on 2/14/2013(UTC)
berinder
#7 Posted : Wednesday, February 13, 2013 2:16:52 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/8/2013(UTC)
Posts: 6
Location: Sweden

Thanks: 2 times
The problem is causes by the CODE_ANALYSIS being on, maybe in combinations with "treat warnings as errors"

The "no custom build steps" is maybe not that true, i remembered that when getting the repo i had to run a powershell script. And, behold, it does inject dlls into the \bin catalog in the project. I only checked to see if the project itself had any problems.

The code analysis log looks like this:
<Exception Keyword="CA0001" Kind="Engine">
<Type>Microsoft.FxCop.Sdk.InvalidMetadataException</Type>
<ExceptionMessage>Unknown constant type.</ExceptionMessage>
<StackTrace> at Microsoft.FxCop.Sdk.MetadataReader.GetValueFromBlob(Int32 type, Int32 blobIndex)
at Microsoft.FxCop.Sdk.Reader.GetLiteral(Int32 parentCodedIndex, TypeNode type)
at Microsoft.FxCop.Sdk.Reader.AddMoreStuffToParameters(Method method, ParameterCollection parameters, Int32 start, Int32 end)
at Microsoft.FxCop.Sdk.Reader.GetMethodFromDef(Int32 index, TypeNode declaringType)
at Microsoft.FxCop.Sdk.Reader.AddMethodsToType(TypeNode type, MethodPtrRow[] methodPtrs, Int32 start, Int32 end)
at Microsoft.FxCop.Sdk.Reader.GetTypeMembers(TypeNode type, Object handle)
at Microsoft.FxCop.Sdk.TypeNode.get_Members()
at Microsoft.FxCop.Sdk.Duplicator.ProvideTypeMembers(TypeNode dup, Object handle)
at Microsoft.FxCop.Sdk.Specializer.ProvideTypeMembers(TypeNode typeNode, Object handle)
at Microsoft.FxCop.Sdk.TypeNode.get_Members()
at Microsoft.FxCop.Sdk.TypeNode.GetMembersNamed(Identifier name)
at Microsoft.FxCop.Sdk.Reader.GetMemberFromRef(Int32 i, TypeNodeCollection&amp; varArgTypes, Int32 numGenericArgs)
at Microsoft.FxCop.Sdk.Reader.GetMemberFromToken(Int32 tok, TypeNodeCollection&amp; varArgTypes)
at Microsoft.FxCop.Sdk.InstructionParser.ParseInstruction()
at Microsoft.FxCop.Sdk.InstructionParser.ParseInstructions()
at Microsoft.FxCop.Sdk.Reader.ParseMethodInstructions(Method method, Int32 methodIndex, Int32 RVA)
at Microsoft.FxCop.Sdk.Reader.GetMethodInstructions(Method method, Object i)
at Microsoft.FxCop.Sdk.Reader.GetMethodBody(Method method, Object i, Boolean asInstructionList)
at Microsoft.FxCop.Sdk.Method.get_Instructions()
at Microsoft.FxCop.Sdk.RuleUtilities.HasImperativeSecurityAction(Method method, SecurityAction action)
at Microsoft.FxCop.Sdk.RuleUtilities.HasSecurityAction(Method method, SecurityAction action)
at Microsoft.FxCop.Sdk.RuleUtilities.HasSecurityAction(Method method, SecurityAction[] actions)
at Microsoft.FxCop.Engines.Introspection.LoadVisitor.RecordCallSites(Method caller)
at Microsoft.FxCop.Engines.Introspection.LoadVisitor.VisitMember(Member member, TargetMember target)
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>

I have tried to add the dlls to the build with a post-build-step, but it dosen't seem to help.

I have traced the bug in the VCS also, and it is introduced in changeset that adds a call to one of the services defined in one of the injected dlls. I'm pretty sure that this is the problem.

Next step is to figure out how to either correct my build or reproduce this ugly solution in the build for nchrunch....
berinder
#8 Posted : Wednesday, February 13, 2013 3:50:12 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/8/2013(UTC)
Posts: 6
Location: Sweden

Thanks: 2 times
I have found a workaround that works for me, for the moment. I can atleast evaluate this product properly now.

Workaround; as reference for anyone that googles this; was for me to set "Use build configuration" to "Release" for the conflicting project. The Release project dosen't have code analysis turned on.

Thanks Remco for your help. The help here will be mentioned in my evaluation. ;)
Remco
#9 Posted : Wednesday, February 13, 2013 8:38:53 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Great to hear! Setting your configuration to 'Release' probably isn't an ideal long term workaround - I recommend having a look at introducing conditional behaviour inside the project file to disable the code analysis when NCrunch is resident. You can probably do this by attaching a condition to the build property.

NCrunch does also disable pre/post build events in its environment by default, although you can easily switch these on if you need them.


Cheers,

Remco

1 user thanked Remco for this useful post.
berinder on 2/14/2013(UTC)
berinder
#10 Posted : Thursday, February 14, 2013 10:17:51 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/8/2013(UTC)
Posts: 6
Location: Sweden

Thanks: 2 times
I have managed to make a project that reproduces the problem, you can find it here: https://www.dropbox.com/...e7u/ReprodueProblem.rar

In short
Project A has a Class C<T>
Class C<T> have a method ViolatingFunction(T param = null)

In Project B Do
var x = new C<Anything>();

Get Unknown Constant Type.

Removing the " = null" will remove the problem.

Leaving this here for anyone experiencing the same problem.
Remco
#11 Posted : Thursday, February 14, 2013 10:31:48 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for the reproduction! I'll take a look :)


Cheers,

Remco
Remco
#12 Posted : Saturday, March 30, 2013 9:45:48 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
For anyone interested, a fix for this problem has been introduced with the newly released version of NCrunch (v1.45).
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.097 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download