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

Notification

Icon
Error

NCrunch 2.1 Fails To Build - ASPRUNTIME error
moosey
#1 Posted : Wednesday, December 4, 2013 9:34:35 AM(UTC)
Rank: Member

Groups: Registered
Joined: 9/6/2011(UTC)
Posts: 12

Was thanked: 2 time(s) in 2 post(s)
Hi Remco,

Just tried NCrunch v2.1 on our solution. It fails to build a project, producing the following error:

Quote:
error ASPRUNTIME (0)#0: Exception has been thrown by the target of an invocation..

NCrunch: The following files are expected but do not seem to exist on the computer responsible for building this project:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets

Please make sure you have all SDKs required to build this project installed on this computer.


The expected files are indeed missing from my PC (I'm using Visual Studio 2012), but NCrunch v1.48 doesn't have any problems with the project.

For the time being, I've reverted back to v1.48.
Remco
#2 Posted : Wednesday, December 4, 2013 10:33:36 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for sharing this issue!

The .targets warning is a red herring - to find the cause of this problem, we'll need to dig behind the ASPRUNTIME to find out why this is appearing.

Sorry, I realise I'm asking you to upgrade and downgrade again, but is there any chance you could submit a bug report right after you've had this build fail? My hope is that the log will give us something revealing. Something else that would be really good to know is whether or not the project builds correctly if you run msbuild.exe against it inside the NCrunch workspace (you can find this by right clicking on the failed build, then going to Advanced->Browse To Workspace).

Right now you're the only lead I have on this problem. I really hope to have it solved for you and get you up and running on V2.


Cheers,

Remco
moosey
#3 Posted : Wednesday, December 4, 2013 1:50:40 PM(UTC)
Rank: Member

Groups: Registered
Joined: 9/6/2011(UTC)
Posts: 12

Was thanked: 2 time(s) in 2 post(s)
Hi Remco,

I've submitted a bug report for you. Here's the output from executing MSBuild in the workspace:

Quote:

MvcBuildViews:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v temp -p
C:\Users\tom.davis\AppData\Local\NCrunch\7384\122\Source2\VoiceXML
error ASPRUNTIME : The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..
[C:\Users\tom.davis\AppData\Local\NCrunch\7384\122\Source2\VoiceXML\VoiceXML.csproj]

...

"C:\Users\tom.davis\AppData\Local\NCrunch\7384\122\Source2\VoiceXML\VoiceXML.csproj" (default target) (1) ->
(MvcBuildViews target) ->
error ASPRUNTIME : The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation.. [C:\Users\tom.davis\AppData\Local\NCrunch\7384\122\Source2\VoiceXML\VoiceXML.csproj]


Hope this helps!

Tom

Remco
#4 Posted : Wednesday, December 4, 2013 11:23:27 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi Tom -

Thanks for the bug report! I'm wondering if I could bug you into trying something else. After the build has failed, can you do the following?

- Right click the failed build in the Tests Window, go to Advanced->Browse To Workspace
- Find the project file in the workspace (VoiceXML.csproj)
- Open a command prompt to this file
- Run the command: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v temp -p -errorstack

This should hopefully give us the exception being thrown behind the scenes. My bet is that is an assembly reference error of some kind. When we know more about this, we can dig through the workspace and find out why the assembly resolution is failing.


Cheers,

Remco
moosey
#5 Posted : Thursday, December 5, 2013 11:30:16 AM(UTC)
Rank: Member

Groups: Registered
Joined: 9/6/2011(UTC)
Posts: 12

Was thanked: 2 time(s) in 2 post(s)
Hi Remco,

It looks like the project can't find the assembly "Ninject.Extensions.Conventions". Here's the stack trace (I've obfuscated some namespaces to protect my client's identity):

Code:
Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.17929
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.

error ASPRUNTIME: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..

[FileNotFoundException]: Could not load file or assembly 'Ninject.Extensions.Conventions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7' or one of its dependencies. The system cannot find the file specified.
   at ****.****.****.DependencyInjection.ModelModule.Load()
   at Ninject.Modules.NinjectModule.OnLoad(IKernel kernel) in c:\Projects\Ninject\ninject\src\Ninject\Modules\NinjectModule.cs:line 85
   at Ninject.KernelBase.Load(IEnumerable`1 m) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 217
   at Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 100
   at Ninject.KernelBase..ctor(INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 57
   at Ninject.StandardKernel..ctor(INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\StandardKernel.cs:line 46
   at ****.****.VoiceXml.App_Start.NinjectWebCommon.CreateKernel() in c:\Users\tom.davis\AppData\Local\NCrunch\3128\117\Source2\VoiceXML\App_Start\NinjectWebCommon.cs:line 86
   at Ninject.Web.Common.Bootstrapper.Initialize(Func`1 createKernelCallback) in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\Bootstrapper.cs:line 50
   at ****.****.VoiceXml.App_Start.NinjectWebCommon.Start() in c:\Users\tom.davis\AppData\Local\NCrunch\3128\117\Source2\VoiceXML\App_Start\NinjectWebCommon.cs:line 62

[TargetInvocationException]: Exception has been thrown by the target of an invocation.
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at WebActivator.BaseActivationMethodAttribute.InvokeMethod()
   at WebActivator.ActivationManager.RunActivationMethods[T]()
   at WebActivator.ActivationManager.RunPreStartMethods()
   at WebActivator.ActivationManager.Run()

[InvalidOperationException]: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..
   at System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures)
   at System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)
   at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath)
   at System.Web.Compilation.BuildManager.ExecutePreAppStart()
   at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

[HttpException]: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..
   at System.Web.Compilation.ClientBuildManager.EnsureHostCreated()
   at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback, Boolean forceCleanBuild)
   at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback)
   at System.Web.Compilation.Precompiler.Main(String[] args)




Ninject.Extensions.Conventions is a nuget package and the project appears to build without any problems in Visual Studio and NCrunch v1.
Remco
#6 Posted : Friday, December 6, 2013 2:28:57 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Right. I think we're getting closer on this.

The ASPNETCOMPILER calls into user code (NinjectWebCommon.cs) as part of its build process. This means any exception thrown during the CreateKernel method will bubble up obscurely as a build error. The missing Ninject.Extensions.Conventions file is a bit of an anomaly, as NCrunch will normally only allow the ASPNETCOMPILER build step to run if the 'Copy Referenced Assemblies To Workspace' setting is enabled for the web project. This is because the ASPNETCOMPILER depends on the referenced assemblies existing in the build output directory.

The good news here is that I can now probably give you a workaround that will let you get past this problem and use this project with V2. Inside your web project file, you'll find a property like:

<MvcBuildViews>true</MvcBuildViews>

Try changing this to:

<MvcBuildViews Condition="$(NCrunch) != '1'">true</MvcBuildViews>
<MvcBuildViews Condition="$(NCrunch) == '1'">false</MvcBuildViews>

.. In this way, NCrunch will avoid the ASPNETCOMPILER step entirely. You may find this is in some ways useful as the ASPNETCOMPILER build step is extremely slow and will greatly increase your build times. The drawback is that NCrunch won't be able to give you real-time feedback on compilation issues inside your MVC views.

With that said, I'd still really like to know why this is failing, because NCrunch should normally be able to handle this build step - and as you've mentioned this was working in V1.

So I'm wondering if you might be able to help me narrow the issue down by answering the following questions:

- Does NCrunch give you any warnings in the Tests Window against the web project? Can you unhide the warnings in this window and let me know which ones are appearing? (I mean the warnings showing in the NCrunch tree, as opposed to MSBuild warnings printed in the build output).
- If you right-click on the failed build, then go to Advanced->Browse To Workspace and find the build output directory (bin), what does this directory contain? Is the web project DLL in there? How about Ninject.Extensions.Conventions and any other referenced assemblies?
- Can you show me the MSBuild XML in your web .proj file that is used to reference the Ninject.Extensions.Conventions assembly?


Thanks!

Remco
moosey
#7 Posted : Wednesday, February 19, 2014 1:27:23 PM(UTC)
Rank: Member

Groups: Registered
Joined: 9/6/2011(UTC)
Posts: 12

Was thanked: 2 time(s) in 2 post(s)
Hi Remco,

Sorry it's taken so long to get back to you on this issue.

- Does NCrunch give you any warnings in the Tests Window against the web project? Can you unhide the warnings in this window and let me know which ones are appearing? (I mean the warnings showing in the NCrunch tree, as opposed to MSBuild warnings printed in the build output).

I am getting "Assemblies are being referenced from the build output of other projects in this solution" and "Copy referenced Assemblies to Workspace is turned on".

- If you right-click on the failed build, then go to Advanced->Browse To Workspace and find the build output directory (bin), what does this directory contain?

It looks like it contains all the DLLs expected.

- Is the web project DLL in there?

Yes

- How about Ninject.Extensions.Conventions and any other referenced assemblies?

No, it's not there!

- Can you show me the MSBuild XML in your web .proj file that is used to reference the Ninject.Extensions.Conventions assembly?

This assembly does not appear to be referenced by the project at all. Perhaps that's what the problem is?

Remco
#8 Posted : Wednesday, February 19, 2014 11:17:55 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Right - I think this all makes sense now!

The Ninject.Extensions.Conventions assembly must be referenced by a dependency of the web project. It's then being loaded dynamically by the web project.. so it's basically an implicit reference.

It may be enough to simply add a reference from the web project to this assembly, otherwise turning on the 'Copy referenced assemblies to workspace' for ALL the dependencies of the web project will also do the trick.

However I do stand by my initial recommendation of disabling the ASPNETCOMPILER step for NCrunch builds, or at the very least disabling the Ninject code when NCrunch is running a build. The 'Copy referenced assemblies to workspace' setting will spike your build times considerably and really slow down the feedback you get from tests.

I'd also like to draw attention to this warning: "Assemblies are being referenced from the build output of other projects in this solution"
This is often a warning that deserves some special attention, as it can cause some pretty weird things to happen. I'd recommend looking into the assemblies involved to see if you have another unrelated problem here that may cause lost time in future.
moosey
#9 Posted : Thursday, March 13, 2014 11:29:18 PM(UTC)
Rank: Member

Groups: Registered
Joined: 9/6/2011(UTC)
Posts: 12

Was thanked: 2 time(s) in 2 post(s)
Hi again Remco,

I followed your advice and sorted out all the NCrunch warnings - it looks like disabling the "Copy referenced assemblies" setting had a significant impact on our feedback time. (Although we are using Ninject, there was no need for this setting to be enabled).

I've documented my findings on my blog (http://blog.rumr.co.uk/improving-ncrunch-performance/) - I'll probably update it over the next few days with some example timings.

Thanks for all your help.

Tom
1 user thanked moosey for this useful post.
Remco on 3/13/2014(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.074 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download