Вопрос

I have a tiny ASP.NET web app that runs fine on windows 7 but fails to run on Windows 2008 R2 with this error. I can't get around why I'm seeing MVC dependency error.
Using .NET 4/VS 2010.

    Exception information: 
    Exception type: ConfigurationErrorsException 
    Exception message: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
   at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
   at System.Web.Configuration.AssemblyInfo.get_AssemblyInternal()
   at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
   at System.Web.Compilation.BuildManager.CallPreStartInitMethods()
   at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)`enter code here`
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
Это было полезно?

Решение

This is most likely caused by sub application config file inheritance. The parent config file has a reference to a library that the sub application doesn't have.

Try to insert this line under system.web --> compilation --> assemblies

<remove assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Другие советы

Are you deploying System.Web.Mvc with your site, or, are you relying on GAC'd copy on your dev machine? You can follow this blog post to bin deploy mvc3 to a server, or you can install mvc3 on the target server using the web platform installer.

If MVC3 is already installed, and you you need to see more details about binding errors, you can enable the fusion log on the target machine.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top