没有找到入口点的例外

时间:2012-10-31 08:52:58

标签: 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 

12 个答案:

答案 0 :(得分:23)

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

答案 1 :(得分:23)

我已将项目从MVC3+.NET4转换为MVC4+.NET4.5,并在调用控制器的操作时收到异常Entry 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>

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

答案 2 :(得分:10)

旧帖但如果您在mvc问题之前遇到它(System.Mvc.dll更新,例如x.0.0.1),您可以检查bindingRedirect标记(4.0.0.0 - &gt; 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> 

答案 3 :(得分:6)

如果您在Web API控制器中捕获此错误 - 您需要修复绑定 版本 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>

答案 4 :(得分:3)

您还应该检查解决方案中的所有项目是否都引用了最新版本的dll,并且不同的子项目没有使用不一致的版本。

尽管运行nuget卸载,安装和更新我发现测试项目引用了旧版本的system.net.http

答案 5 :(得分:3)

如果您使用.net 4.5并从.net 4.0库向ModelBinders.Binders集合添加绑定器,您也会收到此类错误。

答案 6 :(得分: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堆栈跟踪会建议您的一个(或多个)依赖项无法解析。

你可以尝试评论其中一个或多个,并尝试缩小哪一个未能解决。

答案 7 :(得分:0)

旧帖子,但只是为了寻找

的人添加

这似乎是一个抓住所有错误。当我的web.config使用外部部分并且该部分被排除在Visual Studio项目之外时,我得到了它,即使用此

<sessionState configSource="SystemWeb.config" />

答案 8 :(得分:0)

在visual studio中试试..转到Package Administrator Console并输入:

update-package

答案 9 :(得分:0)

我遇到了这个问题,并通过
解决了它 1.卸载 - 打包Microsoft.AspNet.Mvc(我需要先卸载其他内容才能成功卸载AspNet.MVC)
2.安装包Microsoft.AspNet.Mvc -Version 4.0.20710
3.重建和部署

答案 10 :(得分:0)

在我的情况下不是MVC特定的,但刚刚开始收到此错误:

  应用程序中的服务器错误。

     

未找到切入点。

     

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

     

异常详细信息:System.EntryPointNotFoundException:找不到入口点。

     

来源错误:

     

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

     

堆栈追踪:

     

[EntryPointNotFoundException:找不到入口点。]

     

...

     

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

     

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.6.1055.0

是什么导致我从Visual Studio发布到webserver文件夹并选择预编译应用程序(使用.NET 4.5项目),允许预编译站点可更新设置btw。

可能我的问题是该站点在IIS上运行在.NET 4.0上,而在发布操作期间放置在bin文件夹中的预编译版本是4.5。当我从网站上删除“bin”文件夹时,它再次正常运行。

答案 11 :(得分:-2)

只需更新&#34; System.Web.Mvc&#34;用&#34; nuget&#34;