c# - Could not load file or assembly System.Web.Mvc or one of its dependencies -


currently working on asp.net mvc5 (old mvc3 project). builds fine, when start project when run project facing following error.

could not load file or assembly 'system.web.mvc' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040) 

not sure how can can fix this, ideas?

this assembly load trace:

=== pre-bind state information === log: displayname = system.web.mvc  (partial) wrn: partial binding information supplied assembly: wrn: assembly name: system.web.mvc | domain id: 2 wrn: partial bind occurs when part of assembly display name provided. wrn: might result in binder loading incorrect assembly. wrn: recommended provide specified textual identity assembly, wrn: consists of simple name, version, culture, , public key token. wrn: see whitepaper http://go.microsoft.com/fwlink/?linkid=109270 more information , common solutions issue. log: appbase = file:///c:/users/joaki/source/repos/2015-timeadministration/source/v2/salesweb2/timereportv2/ log: initial privatepath = c:\users\joaki\source\repos\2015-timeadministration\source\v2\salesweb2\timereportv2\bin calling assembly : (unknown). === log: bind starts in default load context. log: using application configuration file: c:\users\joaki\source\repos\2015-timeadministration\source\v2\salesweb2\timereportv2\web.config log: using host configuration file: c:\users\joaki\documents\iisexpress\config\aspnet.config log: using machine configuration file c:\windows\microsoft.net\framework\v4.0.30319\config\machine.config. log: policy not being applied reference @ time (private, custom, partial, or location-based assembly bind). log: attempting download of new url file:///c:/users/joaki/appdata/local/temp/temporary asp.net files/root/a90c5137/552c494a/system.web.mvc.dll. log: attempting download of new url file:///c:/users/joaki/appdata/local/temp/temporary asp.net files/root/a90c5137/552c494a/system.web.mvc/system.web.mvc.dll. log: attempting download of new url file:///c:/users/joaki/source/repos/2015-timeadministration/source/v2/salesweb2/timereportv2/bin/system.web.mvc.dll. log: using application configuration file: c:\users\joaki\source\repos\2015-timeadministration\source\v2\salesweb2\timereportv2\web.config log: using host configuration file: c:\users\joaki\documents\iisexpress\config\aspnet.config log: using machine configuration file c:\windows\microsoft.net\framework\v4.0.30319\config\machine.config. log: redirect found in application configuration file: 4.0.0.1 redirected 5.2.3.0. log: post-policy reference: system.web.mvc, version=5.2.3.0, culture=neutral, publickeytoken=31bf3856ad364e35 log: attempting download of new url file:///c:/users/joaki/appdata/local/temp/temporary asp.net files/root/a90c5137/552c494a/system.web.mvc.dll. log: attempting download of new url file:///c:/users/joaki/appdata/local/temp/temporary asp.net files/root/a90c5137/552c494a/system.web.mvc/system.web.mvc.dll. log: attempting download of new url file:///c:/users/joaki/source/repos/2015-timeadministration/source/v2/salesweb2/timereportv2/bin/system.web.mvc.dll. wrn: comparing assembly name resulted in mismatch: major version err: failed complete setup of assembly (hr = 0x80131040). probing terminated. 

web confgg:

    <?xml version="1.0" encoding="utf-8"?> <!--   more information on how configure asp.net application, please visit   http://go.microsoft.com/fwlink/?linkid=301880   --> <configuration>     <connectionstrings>     <add name="saleswebentities" connectionstring= ""/>   </connectionstrings>  <appsettings>     <add key="webpages:version" value="3.0.0.0" />     <add key="webpages:enabled" value="false" />     <add key="clientvalidationenabled" value="true" />     <add key="unobtrusivejavascriptenabled" value="true" />   </appsettings>    <system.web>     <compilation debug="true" targetframework="4.5.1" >       <assemblies>         <add assembly="system.data.entity, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/>       </assemblies>     </compilation>    <authentication mode="forms">     <forms loginurl="~/account/logon" timeout="2880" />   </authentication>    <membership>     <providers>       <clear />       <add name="aspnetsqlmembershipprovider" type="system.web.security.sqlmembershipprovider" connectionstringname="applicationservices" enablepasswordretrieval="false" enablepasswordreset="true" requiresquestionandanswer="false" requiresuniqueemail="false" maxinvalidpasswordattempts="5" minrequiredpasswordlength="6" minrequirednonalphanumericcharacters="0" passwordattemptwindow="10" applicationname="/" />     </providers>   </membership>    <profile>     <providers>       <clear />       <add name="aspnetsqlprofileprovider" type="system.web.profile.sqlprofileprovider" connectionstringname="applicationservices" applicationname="/" />     </providers>   </profile>    <rolemanager enabled="false">     <providers>       <clear />       <add name="aspnetsqlroleprovider" type="system.web.security.sqlroleprovider" connectionstringname="applicationservices" applicationname="/" />       <add name="aspnetwindowstokenroleprovider" type="system.web.security.windowstokenroleprovider" applicationname="/" />     </providers>   </rolemanager>    <pages>     <namespaces>       <add namespace="system.web.mvc" />       <add namespace="system.web.mvc.ajax" />       <add namespace="system.web.mvc.html" />       <add namespace="system.web.routing" />       <add namespace="system.web.helpers" />       <add namespace="system.web.webpages" />     </namespaces>   </pages>   </system.web>    <system.webserver>     <validation validateintegratedmodeconfiguration="false" />     <modules runallmanagedmodulesforallrequests="true" />   </system.webserver>    <runtime>     <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">       <dependentassembly>         <assemblyidentity name="newtonsoft.json" culture="neutral" publickeytoken="30ad4fe6b2a6aeed" />         <bindingredirect oldversion="0.0.0.0-7.0.0.0" newversion="7.0.0.0" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="system.web.optimization" publickeytoken="31bf3856ad364e35" />         <bindingredirect oldversion="1.0.0.0-1.1.0.0" newversion="1.1.0.0" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="webgrease" publickeytoken="31bf3856ad364e35" />         <bindingredirect oldversion="0.0.0.0-1.6.5135.21930" newversion="1.6.5135.21930" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="antlr3.runtime" publickeytoken="eb42632606e9261f" culture="neutral" />         <bindingredirect oldversion="0.0.0.0-3.5.0.2" newversion="3.5.0.2" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="system.web.helpers" publickeytoken="31bf3856ad364e35" />         <bindingredirect oldversion="1.0.0.0-3.0.0.0" newversion="3.0.0.0" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="system.web.webpages" publickeytoken="31bf3856ad364e35" />         <bindingredirect oldversion="1.0.0.0-3.0.0.0" newversion="3.0.0.0" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="system.web.mvc" publickeytoken="31bf3856ad364e35" />         <bindingredirect oldversion="1.0.0.0-5.2.3.0" newversion="5.2.3.0" />       </dependentassembly>     </assemblybinding>   </runtime>  </configuration> 

if read fusion log posted, gives information need. i'll strip down important lines.

log: attempting download of new url file:///c:/users/joaki/source/repos/2015-timeadministration/source/v2/salesweb2/timereportv2/bin/system.web.mvc.dll. 

the app looking system.web.mvc.dll. it's resolved 1 under web app's bin folder: c:\users\joaki\source\repos\2015-timeadministration\source\v2\salesweb2\timereportv2\bin\system.web.mvc.dll

next, checks see if there assembly binding redirect dll in web.config, , finds one:

log: using application configuration file: c:\users\joaki\source\repos\2015-timeadministration\source\v2\salesweb2\timereportv2\web.config log: redirect found in application configuration file: 4.0.0.1 redirected 5.2.3.0. log: post-policy reference: system.web.mvc, version=5.2.3.0, culture=neutral, publickeytoken=31bf3856ad364e35 

if in web.config, there this:

  <dependentassembly>     <assemblyidentity name="system.web.mvc" publickeytoken="31bf3856ad364e35" />     <bindingredirect oldversion="1.0.0.0-5.2.3.0" newversion="5.2.3.0" />   </dependentassembly> 

it checks system.web.mvc.dll it's found in app's bin directory same version:

wrn: comparing assembly name resulted in mismatch: major version err: failed complete setup of assembly (hr = 0x80131040). probing terminated. 

it complains major version mismatches. first number in 4-number version. if go in log, that's because system.web.mvc.dll in bin folder version 4.0.0.1, not desired 5.2.3.0:

log: redirect found in application configuration file: 4.0.0.1 redirected 5.2.3.0. 

you need check solution make sure projects reference system.web.mvc looking same, latest version. if @ warnings in error list, you'll find warnings version mismatches assembly.

updating references

one solution right click on solution in visual studio, choose "manage nuget packages solution..." , try update projects use same version of system.web.mvc.

it if clear out bin folders beforehand.

you can use package manager console instead update package across solution:

update-package microsoft.aspnet.mvc -version 5.2.3.0 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -