2012-12-05 101 views
0

我製作了一個模塊化應用程序,每個模塊都是一個單獨的項目,它們外觀與MVC區域相似。Visual Studio中的Intellisense錯誤

我實現了一個自定義WebViewPage,但即使將指針從web.config移回缺省值,intellisense仍然無法正常工作。

在我的Razor視圖的第一行:

@model IEnumerable<Module2.Models.TestModel> 

我得到警告:

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

和錯誤:

​​

然後每次我嘗試一次引用該模型出現錯誤:

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

此外,如果我添加ViewBag.Title到視圖我得到這個錯誤:

One or more types required to compile a dynamic expression cannot be found. Are you missing a reference? xxx\Module2\Views\Shared\TestModelTable.cshtml

我會假設有與網絡CONFIGS一個問題,但他們是在MVC地區發現標準的web CONFIGS(我刪除了定製WebPageView

這發生在我嘗試在每個模塊中創建的每個視圖,但主應用程序工作正常。因此我試圖將主應用程序的網頁配置複製到模塊中,但我仍然有很多錯誤。


更新 12年6月12日

固定RazorBuildProvider的實現來處理模塊中的應用程序現在可以成功地呈現強類型的意見後。然而,intellisense仍然會導致這些錯誤。我懷疑@module...行上的第一個錯誤是罪魁禍首,並且阻止編輯器加載強類型模型所需的信息。


更新 12年6月12日

通過排除法,我已經想通了,ninject的PreApplicationStartMethod是罪魁禍首。當方法調用RegisterServices時,我的模塊加載器被調用,並且在那裏引發錯誤。 [assembly: WebActivator.PreApplicationStartMethod(typeof(Frontline.App_Start.NinjectWebCommon), "Start")]

爲了更好的解決方案,我需要弄清楚如何正確地調試這個錯誤,所以我已經張貼另一個(更通用的)問題上的SO Debugging Visual Studio editor exceptions

我還要交我找不到任何東西我的哈克修復作爲答案

回答

0

所以我一直沒能解決問題的根源,但我有一個快速修復。

我我的模塊加載方法在查殺過程中,如果它在名稱視覺工作室:

if (System.Diagnostics.Process.GetCurrentProcess().ProcessName.Contains("VisualStudio")) 
    return;