2012-10-31 34 views
28

我已經安裝了vs2012 (11.0.50727.1)
我新開了一家MVC4 with .NET 4.5解決方案,
我創建一個簡單的HomeController和我一直想在本地啓動它,我收到這個非常奇怪的錯誤:
如何解決它?這個錯誤是什麼,爲什麼發生?入口點未發現異常

非常感謝您的幫助。

Server Error in '/' Application. 
Entry point was not found. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.EntryPointNotFoundException: Entry point was not found. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


[EntryPointNotFoundException: Entry point was not found.] 
    System.Web.Mvc.IDependencyResolver.GetService(Type serviceType) +0 
    System.Web.Mvc.DependencyResolverExtensions.GetService(IDependencyResolver resolver) +56 
    System.Web.Mvc.SingleServiceResolver`1.GetValueFromResolver() +44 
    System.Lazy`1.CreateValue() +180 
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +22 
    System.Lazy`1.get_Value() +10749357 
    System.Web.Mvc.SingleServiceResolver`1.get_Current() +15 
    System.Web.Mvc.MvcRouteHandler.GetSessionStateBehavior(RequestContext requestContext) +121 
    System.Web.Mvc.MvcRouteHandler.GetHttpHandler(RequestContext requestContext) +33 
    System.Web.Mvc.MvcRouteHandler.System.Web.Routing.IRouteHandler.GetHttpHandler(RequestContext requestContext) +10 
    System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +9709656 
    System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82 
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929 

回答

22

當您將項目從MVC3切換到MVC4並忘記在web.config中將System.Web.WebPages.Razor, Version=1.0.0.0更改爲System.Web.WebPages.Razor, Version=2.0.0.0時,會出現相同的錯誤。

2

在Global.asax.cs中是否有類似的內容?

private static void InitializeDependencyInjectionContainer(HttpConfiguration config) 
{ 
    container = new UnityContainer(); 


    container.RegisterType<Site.Web.Data.IDatabaseFactory, Site.Web.Data.DatabaseFactory>(); 
    container.RegisterType<Site.Web.Data.Interfaces.IUnitOfWork, Site.Web.Data.UnitOfWork>(); 
    container.RegisterType<Site.Web.Data.Interfaces.IUserRepository, Site.Web.Data.Repositories.UserRepository>(); 
    container.RegisterType<Site.Web.Data.Interfaces.ISiteRepository, Site.Web.Data.Repositories.SiteRepository>(); 

從您發佈System.Web.Mvc.IDependencyResolver.GetService(Type serviceType) +0堆棧跟蹤會建議你的依賴沒有解決的一個(或多個)。

您可以嘗試對其中的一個或多個發表評論,並嘗試縮小哪個未能解決。

+0

沒有,在MVC有配發了迪入口點,這不是它。 – IamStalker

+0

對我來說,這是一個恥辱,我不知道如何解決它... –

22

我已將項目從MVC3+.NET4轉換爲MVC4+.NET4.5,並且在調用控制器的操作時收到異常Entry point was not found

我的解決辦法是在MVC 4組件插入組件結合內部的web.config點重定向:

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 

我不知道這個問題的確切原因,也許有些第三方庫仍然引用MVC3。

+0

這使它對我來說,顯然SimpleInjector迫使我做到這一點... –

+1

MVC3的Unity IoC容器(用於MVC4)也需要這些綁定。 – hross

+1

此解決方案適用於我。我已更新到MVC 4,但綁定重定向oldVersion仍指向1.0.0.0-2.0.0.0,而newVersion指向3.0.0.0。希望將來一個更有用的錯誤信息將表明配置條目是問題,而不是說找不到入口點。 – Irish

3

您還應該檢查解決方案中的所有項目是否引用了dll的最新版本,並且沒有不同的子項目使用不一致的版本。

儘管運行的NuGet卸載,安裝和更新,我發現如果您使用的是.NET 4.5和添加粘合劑ModelBinders.Binders集中的測試項目引用舊版本的system.net.http

+0

謝謝!我正在使用不同的版本...對我感到羞恥 – Apolo

3

的.net 4.0庫,你也會得到這樣的錯誤。

5

如果你在的WebAPI控制器趕上這個錯誤 - 你需要修復效力之版本的 System.Web.Http

<dependentAssembly> 
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> 
</dependentAssembly> 
0

舊職位,但只是添加任何人都希望

這似乎像一個捕獲所有錯誤。我得到了它,當我的web.config使用外部部分,該部分用這個

<sessionState configSource="SystemWeb.config" /> 
10

舊後從Visual Studio項目,即排除,但是如果你遇到它之前的MVC困境(System.Mvc。 DLL更新例如x.0.0.1)你可以檢查bindingRedirect標記(4.0.0.0 - > 4.0.0。1)

<dependentAssembly> 
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.1" /> 
    </dependentAssembly> 
+0

這爲我修復了...因爲MVC更新而升級時我必須這樣做。謝謝! – derivation

0

試試這個..在Visual Studio中去包管理員控制檯,輸入:

update-package 
0

我面對這個問題,並通過
1卸載,包裝Microsoft.AspNet解決它。 MVC(我需要卸載其他東西之前,我可以成功卸載ASPNET.MVC)
2.安裝,包裝Microsoft.AspNet.Mvc -Version 4.0.20710
3.重建和部署

0

不MVC具體我的情況,但剛開始收到此錯誤:

Server Error in '/' Application.

Entry point was not found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.EntryPointNotFoundException: Entry point was not found.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[EntryPointNotFoundException: Entry point was not found.]

...

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8008

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0

什麼原因造成的是,我已經發布到從Visual Studio Web服務器文件夾並選擇預編譯應用程序(使用.NET 4.5項目),允許預編譯的站點可以更新設置順便說一句。

可能我的問題是,該網站在IIS上運行在.NET 4.0上,而在發佈操作期間放置在bin文件夾中的預編譯版本是4.5。當我從網站上刪除「bin」文件夾時,它再次正常運行。

-2

剛剛更新「System.Web.Mvc」與「的NuGet」