Build/Test Issues

NullReferenceException building test project

Started by maddax on 7,573 views

Hi,

I'm trying out NCrunch for the first time. The video looks really promising.

I get the following error when building the project via NCrunch. Building it directly works fine.

(0): System.NullReferenceException: Object reference not set to an instance of an object.
at Mono.Cecil.Cil.CodeReader.MoveTo(Int32 rva)
at Mono.Cecil.Cil.CodeReader.ReadMethodBody()
at Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
at Mono.Cecil.MethodDefinition.<get_Body>b__2(MethodDefinition method, MetadataReader reader)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at Mono.Cecil.MethodDefinition.get_Body()
at nCrunch.Compiler.ILManipulator.#=qrtjCCeJ8cpgmrVjTjltwcwMwgcoYjxiDAfwLCobhvwg=(Collection`1 #=qePAxKcGbEvsoD6JG4hmGtQ==)
at nCrunch.Compiler.ILManipulator.#=qv714_ylBCYqkXTaep6p6996llk6MzHyNcFcHcBU3iJc=(IEnumerable`1 #=qn$mhNmyKMrpUUahZ$GCRqw==)
at nCrunch.Compiler.ILManipulator.ProcessAssembly(String compiledAssemblyFilePath, Boolean instrumentAssembly, IList`1 referencedAssemblies)
at nCrunch.Compiler.RemoteBuildRunner.#=q0uoBxrNlTkjmTSaxJhYlkQrKe_8WNPmit72NeowJC3s=(ComponentBuildParameters #=qCn0HgHIPPJdr$MwJ5iYsMw==, String #=qb05IZ2bLgQYgLTiHuoQfWea6UIyV9UtiGonMsT$9U6A=, BuildOutput #=qCM8XL7dpUexUEnvWKXQW7g==, String #=qrkYYOthLpeqZ$SKMUKGPIZHg$j4NbswsFmroxjnM2dQ=)
at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)

Any ideas? I'm using NCrunch for Visual Studio 2010 1.34.0.0b. It's an NUnit test project.

Thanks,
Matthew
This is a problem caused by instrumentation. Most likely your assembly has a certain IL arrangement that isn't supported by NCrunch. Try turning off instrumentation on this project to see if that makes a difference. If there's any way for me to have a copy of the assembly (.dll) that's causing this, I'd really like to have a look at the IL inside it - though I understand this may not always be possible if you are working on a commercial project.
Thanks for the quick response. Unfortunately, this is a commercial project so I can't send the code. I've tried (unsuccessfully) recreating it in a dummy project.

I also noticed that there doesn't yet seem to be support for NUnit test attributes (Values(...), ValueSource(...) etc.), which is something we make heavy use of, so I'll probably put the trial on hold for now (or maybe start using NCrunch with personal projects).

Kind regards,
Matthew
For anyone experiencing the above issue - I've had a look at this in detail and unfortunately it isn't an easy one to fix.

One common cause of the issue stems from the use of COM interfaces in assemblies that NCrunch is attempting to instrument. If you are unlucky enough to have this problem, the best I can recommend at the moment is switching off instrumentation for the offending assembly.

Meanwhile please be advised that I'm working on a fix for this issue as part of a longer term plan.

Post a reply

Log in to reply.