ASP MVC 5:具有显示名称' System.Web.Http'的程序集。无法加载异常,然后无缝运行

时间:2015-08-03 14:47:27

标签: c# asp.net asp.net-mvc

我在启动MVC应用程序时遇到以下异常,我甚至没有引用该程序集(是的,我知道我引用的其他程序集可以引用它。)

"具有显示名称' System.Web.Http'未能加载"

public class MvcApplication : HttpApplication
{
    protected void Application_Start()
    {
        // I am getting the exception here:
        AreaRegistration.RegisterAllAreas();
        /...
    }
}

例外的完整文本如下:

The assembly with display name 'System.Web.Http' failed to load in the 'Load' 
binding context of the AppDomain with ID 2. The cause of the failure was:   
System.IO.FileNotFoundException: Could not load file or assembly 
'System.Web.Http, Version=5.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot 
find the file specified.

在跳过此异常后,一切似乎都正常工作仍然不是一种舒服的感觉,不知道发生了什么。

要回答评论,这是我的nuget:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Antlr" version="3.5.0.2" targetFramework="net451" />
  <package id="AutoMapper" version="3.3.1" targetFramework="net451" />
  <package id="bootstrap" version="3.3.4" targetFramework="net451" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="fasterflect" version="2.1.3" targetFramework="net451" />
  <package id="jQuery" version="2.1.4" targetFramework="net451" />
  <package id="jquery.TypeScript.DefinitelyTyped" version="2.2.6" targetFramework="net451" />
  <package id="jQuery.Validation" version="1.13.1" targetFramework="net451" />
  <package id="log4net" version="2.0.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Facebook" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Twitter" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
  <package id="Moment.js" version="2.10.3" targetFramework="net451" />
  <package id="Moment.Timezone.js" version="0.4.0" targetFramework="net451" />
  <package id="moment.TypeScript.DefinitelyTyped" version="1.0.6" targetFramework="net451" />
  <package id="moment-timezone.TypeScript.DefinitelyTyped" version="0.0.5" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net451" />
  <package id="Ninject" version="3.2.2.0" targetFramework="net451" />
  <package id="Ninject.MVC5" version="3.2.1.0" targetFramework="net451" />
  <package id="Ninject.Web.Common" version="3.2.3.0" targetFramework="net451" />
  <package id="Ninject.Web.Common.WebHost" version="3.2.3.0" targetFramework="net451" />
  <package id="NodaTime" version="1.3.1" targetFramework="net451" />
  <package id="Owin" version="1.0" targetFramework="net451" />
  <package id="PayPal" version="1.5.0" targetFramework="net451" />
  <package id="PluralTouch.DataAccess" version="1.2015.07.10" targetFramework="net451" />
  <package id="PluralTouch.DependencyInjection" version="1.2015.07.10" targetFramework="net451" />
  <package id="PluralTouch.DependencyInjection.Ninject" version="1.2015.07.10" targetFramework="net451" />
  <package id="PluralTouch.Logging" version="1.2015.07.10" targetFramework="net451" />
  <package id="PluralTouch.Logging.Log4Net" version="1.2015.07.10" targetFramework="net451" />
  <package id="PluralTouch.Mvc" version="1.2015.07.10" targetFramework="net451" />
  <package id="PluralTouch.Utils" version="1.2015.07.10" targetFramework="net451" />
  <package id="Portable.Licensing" version="1.1.0" targetFramework="net451" />
  <package id="T4MVC" version="3.15.4" targetFramework="net451" />
  <package id="T4MVCExtensions" version="3.15.4" targetFramework="net451" />
  <package id="TwitterBootstrapMVC.Eyecon.Datepicker.MVC5" version="1.0.32" targetFramework="net451" />
  <package id="TwitterBootstrapMVC.Flaty.MVC5" version="1.0.29" targetFramework="net451" />
  <package id="TwitterBootstrapMVC5" version="3.16.1" targetFramework="net451" />
  <package id="underscore.js" version="1.8.2" targetFramework="net451" />
  <package id="underscore.TypeScript.DefinitelyTyped" version="0.5.6" targetFramework="net451" />
  <package id="WebActivatorEx" version="2.0.6" targetFramework="net451" />
  <package id="WebGrease" version="1.6.0" targetFramework="net451" />
</packages>

这是调用堆栈:

    mscorlib.dll!System.Reflection.RuntimeModule.GetTypes() + 0xa bytes
    mscorlib.dll!System.Reflection.Assembly.GetTypes() + 0x47 bytes
    System.Web.Mvc.dll!System.Web.Mvc.TypeCacheUtil.FilterTypesInAssemblies(System.Web.Mvc.IBuildManager buildManager = { System.Web.Mvc.BuildManagerWrapper}, System.Predicate<System.Type> predicate = { Method = Cannot evaluate expression because the code of the current method is optimized.}) + 0xf2 bytes
    System.Web.Mvc.dll!System.Web.Mvc.TypeCacheUtil.GetFilteredTypesFromAssemblies(string cacheName = "MVC-AreaRegistrationTypeCache.xml", System.Predicate<System.Type> predicate = { Method = Cannot evaluate expression because the code of the current method is optimized.}, System.Web.Mvc.IBuildManager buildManager = { System.Web.Mvc.BuildManagerWrapper }) + 0x84 bytes
    System.Web.Mvc.dll!System.Web.Mvc.AreaRegistration.RegisterAllAreas(System.Web.Routing.RouteCollection routes = Count = Cannot evaluate expression because the code of the current method is optimized., System.Web.Mvc.IBuildManager buildManager = { System.Web.Mvc.BuildManagerWrapper}, object state = null) + 0x6f bytes
    System.Web.Mvc.dll!System.Web.Mvc.AreaRegistration.RegisterAllAreas(object state = null) + 0x4c bytes
    System.Web.Mvc.dll!System.Web.Mvc.AreaRegistration.RegisterAllAreas() + 0x19 bytes  
    >   ComiCalc.Web.dll!ComiCalc.Web.MvcApplication.Application_Start() Line 21 + 0x6 bytes C#
        [Native to Managed Transition]
        System.Web.dll!System.Web.HttpApplication.InvokeMethodWithAssert(System.Reflection.MethodInfo method, int paramCount, object eventSource, System.EventArgs eventArgs) + 0x81 bytes
         System.Web.dll!System.Web.HttpApplication.ProcessSpecialRequest(System.Web.HttpContext context = { System.Web.HttpContext}, System.Reflection.MethodInfo method, int paramCount, object eventSource, System.EventArgs eventArgs, System.Web.SessionState.HttpSessionState session) + 0xef bytes
    System.Web.dll!System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(System.Web.HttpContext context = { System.Web.HttpContext}, System.Web.HttpApplication app) + 0x137 bytes
    System.Web.dll!System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(System.IntPtr appContext = 52497432, System.Web.HttpContext context = { System.Web.HttpContext}, System.Reflection.MethodInfo[] handlers) + 0x77 bytes
    System.Web.dll!System.Web.HttpApplication.InitSpecial(System.Web.HttpApplicationState state, System.Reflection.MethodInfo[] handlers, System.IntPtr appContext = 52497432, System.Web.HttpContext context) + 0xad bytes
    System.Web.dll!System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(System.IntPtr appContext, System.Web.HttpContext context) + 0x161 bytes
    System.Web.dll!System.Web.Hosting.PipelineRuntime.InitializeApplication(System.IntPtr appContext = 52497432) + 0x129 bytes
    [Appdomain Transition]
    [Native to Managed Transition]

0 个答案:

没有答案