没有找到入口点的例外

Iam*_*ker 29 asp.net-mvc-4 .net-4.5

我已经安装了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 
Run Code Online (Sandbox Code Playgroud)

Dav*_*rdi 24

我已将项目转换为MVC3+.NET4,MVC4+.NET4.5Entry point was not found在调用控制器的操作时收到异常.

我的解决方案是在web.config中插入一个程序集绑定重定向来指向MVC 4程序集:

  <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>
Run Code Online (Sandbox Code Playgroud)

我不知道问题的确切原因,也许某些第三方库仍然引用MVC3.


小智 23

将项目从MVC3切换到MVC4时忘记更改System.Web.WebPages.Razor, Version=1.0.0.0System.Web.WebPages.Razor, Version=2.0.0.0web.config 时出现相同的错误.


小智 10

旧帖子,但如果你在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> 
Run Code Online (Sandbox Code Playgroud)


ZOX*_*IVO 6

如果您在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>
Run Code Online (Sandbox Code Playgroud)