I’ve made a modular application and each module is a separate project, they are of similar appearance to MVC areas.
I implemented a custom WebViewPage but even after removing the pointer from web.config back to default the intellisense is still dysfunctional.
On the first line of my razor view:
@model IEnumerable<Module2.Models.TestModel>
I get the warning:
xxx\Module2\Views\Shared\TestModelTable.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\Module2\Views\Shared\TestModelTable.cshtml
And the error:
The name ‘model’ does not exist in the current context xxx\Module2\Views\Shared\TestModelTable.cshtml
Then each time I try to reference the model an error appears:
The type arguments for method ‘System.Web.Mvc.Html.DisplayExtensions.DisplayFor(System.Web.Mvc.HtmlHelper,
System.Linq.Expressions.Expression>)’
cannot be inferred from the usage. Try specifying the type arguments
explicitly. xxx\Module2\Views\Shared\TestModelTable.cshtml 26 14 Module2
Additionally if I add ViewBag.Title to the view I get this error:
One or more types required to compile a dynamic expression cannot be found. Are you missing a
reference? xxx\Module2\Views\Shared\TestModelTable.cshtml
I would assume there was is a problem with the web configs but they are standard web configs found in mvc areas (I removed the custom WebPageView)
This happens for every view I try to create in each module, however the main application works fine. As a result I attempted to copy the webconfigs from the main application to the module but I still had a lot of errors.
Update 6/12/12
After fixing the implementation of RazorBuildProvider to handle modules the app can now successfully render strongly typed views. However the intellisense still renders these errors. I suspect the first error on the @module... line is the culprit and is preventing the editor from loading the required information for the strongly typed model.
Update 6/12/12
Via a process of elimination I’ve figured out that ninject’s PreApplicationStartMethod is the culprit. When the method calls RegisterServices my moduleloader is called and an error is thrown somewhere in there. [assembly: WebActivator.PreApplicationStartMethod(typeof(Frontline.App_Start.NinjectWebCommon), "Start")]
For a better solution i need to figure out how to debug this error properly, I couldn’t find anything so I’ve posted another (more generic) question on SO Debugging Visual Studio editor exceptions
I’ll also post my hacky fix as an answer
So I haven’t been able to solve the root of the problem but i have a quick fix.
I’m killing the process during my module loading method if it has visual studio in the name: