Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NinjectMVC3's WebActivator.PreApplicationStartMethod assembly attribute causing warnings in my view source editors

When using NinjectMVC3's WebActivator.PreApplicationStartMethod attribute in my web application,

[assembly: WebActivator.PreApplicationStartMethod(typeof(MyProject.App_Start.NinjectMVC3), "Start")]

I am seeing the following warning in each of my view source editor files:

xxx.cshtml: ASP.NET runtime error: 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.. xxx.cshtml 1 1

it manifests itself as a blue-squiggly on the first line of each of my view files (e.g. a @using or @model declaration). Note that the application runs just fine, the problem is only while editing my view source files (visual studio real-time error / warning analysis).

I can verify that WebActivator.PreApplicationStartMethod is the cause by commenting it out.

How can I fix this?

like image 938
Stephen Swensen Avatar asked Nov 05 '22 06:11

Stephen Swensen


1 Answers

WebActivator is not a component of Ninject, it's provided by Microsoft, and maintained by David Ebbo, an architect on the MVC team. Ninject is just using WebActivator to install itself without having to modify global.asax.

Clearly you have some configuration incorrect as this should not be happening. Are you using some third party editor, like Resharper or CodeRush?

Make sure you have the latest version of WebActivator (use NuGet to update). Also, are you using any other extensions?

I can't understand how this can affect your design-time view, since this attribute should only take effect when the application is running. The only thing I can think of is that a third party extension is getting tripped up by parsing the line, and is causing the problem.

Try disabling all extensions and see if the problem remains.

like image 58
Erik Funkenbusch Avatar answered Nov 09 '22 14:11

Erik Funkenbusch