0
votes

I got myself into some problems, when trying to load a solution (GMap.NET), which I had some problems to build. Not sure that matters now though.

I am developing a small system in Visual Studio 2015, which also has a MVC project. When I launch the basic website - more or less just the initial MVC 5 template - through Visual Studio 2015 - that uses IIS Express - I get this error message:

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]

I don't know where the version 1.0.0.0 is coming from! The version I am referencing is 3.0.0.0...

Also - If I publish to my local IIS - it works! I have opened the same solution on two other computers - and there I can launch it from Visual Studio! That means - the problem is on my computer - not in my solution... I am pretty sure.

I suspect that something is messed up on the machine. Maybe in GAC, or some config, but I don't know where... I am thinking on files like this (not that I know much about them):

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

For GAC it doesn't seem that there is the System.Web.WebPages.Deployment.dll. And as it works on the "real" IIS, it must also be ok there.

I also tried to delete all files in 'C:/Users/#user#/AppData/Local/Temp/Temporary ASP.NET Files/vs/'

That should narrow it down to this: - The problem must have something to do with Visual Studio and/or IIS Express - and/or some configuration file. - not a problem with the references in the solution. (I used nuget to install MVC)

Fx. in this file, there is an entry with System.Web.WebPages.Deployment version 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>

But I already tried to uncomment it. No difference...

So if anybody can give me a hint where to look... files to compare or something, I will appreciate it a lot!

Here is the full message that I get:

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

1
I wonder whether another config on your machine is causing the problem. In those lines you commented out, what happens if you leave the remove entry bit comment out the add?Dan Def
I have now tried to leave the remove section. Meaning now it is only the add section the is commented out: Like this: <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" /> -->jma73
Are you using a true value of UseGlobalApplicationHostFile in your project?Dan Def
Wow the issues is now solved: There is also this file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config - and it was in that file that I, apparantly should remove the entries like: '<add assembly="System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />' It did not help to remove in this file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config Only took me 3 days to figure out... Hope it will help somebody else one day!jma73

1 Answers

1
votes

The solution was as mentioned in my previous comment, that - as there are two (x86 and x64) web.config files under the .NET Framework (for that version, 4): C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.con‌​fig C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config - then, when I remove entries of 'System.Web.WebPages.Deployment' in both files it works!

I am not sure how they were added to the project - but I suspect something went wrong when I tried to use GMap.Net (http://greatmaps.wikia.com/wiki/Main_Page) - and had problems with building it.