Visual Studio的IIS Express:无法加载文件或程序集

问题描述:

当我尝试加载一个解决方案(GMap.NET)时,我遇到了一些问题,我有一些问题需要构建。不过现在还不确定。Visual Studio的IIS Express:无法加载文件或程序集

我正在Visual Studio 2015中开发一个小系统,它也有一个MVC项目。当我启动了基本的网站 - 或多或少刚刚起步MVC 5模板 - 通过Visual Studio 2015年 - 使用IIS快递 - 我收到此错误信息:

Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 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.IO.FileLoadException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) [There is more]

我不知道在哪里的1.0版本。 0.0来自!我参考的版本是3.0.0.0 ...

另外 - 如果我发布到我的本地IIS - 它的作品! 我在另外两台电脑上打开了相同的解决方案 - 我可以从Visual Studio启动它! 这意味着 - 问题出在我的电脑上 - 不在我的解决方案中......我非常肯定。

我怀疑机器上的东西弄乱了。也许在GAC,或一些配置,但我不知道在哪里......我想在这样的文件(不,我对他们了解不多):

  • C:\ WINDOWS \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Config \ web.config
  • C:\ Users \\ Documents \ IISExpress \ config \ aspnet.config
  • ??? ???

对于GAC,似乎没有System.Web.WebPages.Deployment.dll。因为它在“真正的”IIS上运行,所以它也必须在那里运行。

我也试着删除所有文件 'C:/用户/用户##/应用程序数据/本地/温度/ ASP.NET临时文件/ VS /'

这应该缩小它这样的: - 问题必须与Visual Studio和/或IIS Express和/或某个配置文件有关。 - 与解决方案中的参考不存在问题。 (我用nuget安装MVC)

Fx。在这个文件中,有一个与System.Web.WebPages.Deployment版本1.0.0.0条目: C:\ WINDOWS \ Microsoft.NET \ Framework64 \ v4.0.30319 \ CONFIG \ web.config中:

<compilation> 
    <assemblies> 
<!-- <remove assembly="System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
     <add assembly="System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> -->` 
... 
</compilation> 

但我已经试图取消注释。没有区别...

所以,如果任何人都可以给我一个提示在哪里看...文件比较什么的,我会很感激!

以下是完整的消息,我得到:正如我在以前的评论中提到

Server Error in '/' Application.

Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 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.IO.FileLoadException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under executable C:\Program Files (x86)\IIS Express\iisexpress.exe --- A detailed error log follows.

=== Pre-bind state information === LOG: DisplayName = System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (Fully-specified) LOG: Appbase = file:///C:/Users/#user#/Source/Workspaces/MySystem/MySystem/Frontend.Web/ LOG: Initial PrivatePath = C:\Users#user#\Source\Workspaces\MySystem\MySystem\Frontend.Web\bin

Calling assembly : (Unknown).

LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users#user#\Source\Workspaces\MySystem\MySystem\Frontend.Web**web.config** LOG: Using host configuration file: C:\Users#user#\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG: Attempting download of new URL file:///C:/Users/#user#/AppData/Local/Temp/Temporary ASP.NET Files/vs/0c78498f/ece65cb2/System.Web.WebPages.Deployment.DLL. LOG: Attempting download of new URL file:///C:/Users/#user#/AppData/Local/Temp/Temporary ASP.NET Files/vs/0c78498f/ece65cb2/System.Web.WebPages.Deployment/System.Web.WebPages.Deployment.DLL. LOG: Attempting download of new URL file:///C:/Users/#user#/Source/Workspaces/MySystem/MySystem/Frontend.Web/bin/System.Web.WebPages.Deployment.DLL. WRN: Comparing the assembly name resulted in the mismatch: Major Version ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Stack Trace:

[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0 System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21 System.Reflection.Assembly.Load(String assemblyString) +28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +57 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290 System.Web.Compilation.BuildManager.ExecutePreAppStart() +157 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531

[HttpException (0x80004005): Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9963380 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

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

+0

我想知道您的机器上是否有其他配置导致此问题。在你注释掉的那些代码行中,如果你将删除条目位注释掉了,会发生什么? –

+0

我现在试图离开删除部分。这意味着现在只有添加部分被注释掉了: 像这样: - > – jma73

+0

您是否在项目中使用了UseGlobalApplicationHostFile的真实值? –

的解决方案是,那 - 因为有两下(x86和x64)的web.config文件。 NET框架(对于该版本,4): C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Config \ web.con图C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Config \ web.config - 然后,当我在两个文件中删除了“System.Web.WebPages.Deployment”条目时,它就起作用了!

我不知道他们是如何被添加到项目中的 - 但我怀疑当我尝试使用GMap.Net(http://greatmaps.wikia.com/wiki/Main_Page)时出现了问题 - 并且在构建它时遇到了问题。