c# - AssemblyBinding BindingRedirect not working for MVC4 app with T4MVCExtensions -


we have large .net web application mvc3, using t4mvc. upgraded mvc4, , except t4mvcextensions (version 3.6.5 nuget) still dependent on system.web.mvc version 3. runtime dependencies you're supposed setup in web.config should redirecting assembly bindings, don't seem be. following exception occurs:

index out of range. must non-negative , less size of collection. parameter name: index  description: unhandled exception occurred during execution of current web     request. please review stack trace more information error , originated in code.   exception details: system.argumentoutofrangeexception: index out of range. must non-negative , less size of collection. parameter name: index 

we've got following in our web.config file, should mapping it, doesn't seem -

<runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">   <dependentassembly>     <assemblyidentity name="system.web.helpers"                       publickeytoken="31bf3856ad364e35" />     <bindingredirect oldversion="1.0.0.0" newversion="2.0.0.0" />   </dependentassembly>   <dependentassembly>     <assemblyidentity name="system.web.mvc"                       publickeytoken="31bf3856ad364e35" />     <bindingredirect oldversion="1.0.0.0-3.0.0.0" newversion="4.0.0.0" />   </dependentassembly>   <dependentassembly>     <assemblyidentity name="system.web.webpages"                       publickeytoken="31bf3856ad364e35" />     <bindingredirect oldversion="1.0.0.0" newversion="2.0.0.0" />   </dependentassembly> </assemblybinding> 

i've enabled fusion log, verify craziness really, , see that, yes indeed, seem trying use mvc3 binary, , not going 4:

*** assembly binder log entry  (5/21/2013 @ 3:37:23 pm) ***  operation failed. bind result: hr = 0x80004005. unspecified error  assembly manager loaded from:  c:\windows\microsoft.net\framework64\v4.0.30319\clr.dll running under executable  c:\windows\system32\inetsrv\w3wp.exe --- detailed error log follows.   === pre-bind state information === log: user = iis apppool\asp.net v4.0 log: displayname = system.web.mvc, version=3.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35  (fully-specified) log: appbase = file:///c:/work/webs/ssuapp/ssuapp/ log: initial privatepath = c:\work\webs\ssuapp\ssuapp\bin log: dynamic base = c:\windows\microsoft.net\framework64\v4.0.30319\temporary asp.net files\lssapp\7a6e6cde log: cache base = c:\windows\microsoft.net\framework64\v4.0.30319\temporary asp.net files\lssapp\7a6e6cde log: appname = d5bcf9a8 calling assembly : app_web__managerulespartial.cshtml.38bccb18.jb5ozz39, version=0.0.0.0, culture=neutral, publickeytoken=null. === log: start validating dependencies. log: [level 1]start validating native image dependency mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089. log: [level 1]start validating il dependency system.componentmodel.dataannotations, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35. log: [level 1]start validating il dependency system.web, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a. log: [level 1]start validating native image dependency system.core, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089. log: [level 1]start validating native image dependency system, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089. log: [level 1]start validating il dependency system.web.razor, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35. log: [level 1]start validating il dependency system.web.webpages.razor, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35. log: [level 1]start validating il dependency system.web.webpages, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35. log: [level 1]start validating il dependency system.runtime.caching, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a. log: [level 1]start validating il dependency microsoft.web.infrastructure, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35. log: [level 1]start validating il dependency system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35. log: [level 1]start validating il dependency system.xml, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089. log: [level 1]start validating il dependency system.data.linq, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089. log: [level 1]start validating il dependency system.data.entity, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089. native image has correct version information. log: validation of dependencies succeeded. log: bind native image succeeded. attempting use native image c:\windows\assembly\nativeimages_v4.0.30319_64\system.web.mvc\f234ba2bcf5f845279e46dc04198a7cd\system.web.mvc.ni.dll. rejecting code sharing because dependent assembly did not match conditional aptca share mode native image used. 

any ideas rock, since i've burned bunch of hours on this.

thanks, francis

i had similar assembly binding issue, after manually upgrading set of mvc3 projects mvc4. despite having assembly binding elements in web.config, getting errors similar t4mvc errors telerik mvc extensions.

the fusion log viewer useful confirmed 2 versions of system.web.mvc being loaded application domain.

in end, removing namespace root configuration element in project's root web.config resolved issue.

so, web.config this:

<?xml version="1.0" encoding="utf-8"?> <configuration xmlns="http://schemas.microsoft.com/.netconfiguration/v2.0"> <!--... elements deleted clarity ...--> </configuration> 

and after removing namespace looks this:

<?xml version="1.0" encoding="utf-8"?> <configuration> <!--... elements deleted clarity ...--> </configuration> 

this blog post has more information erroneous namespace: http://www.dotnetish.com/runtime/xmlnshttpschemas-microsoft-com-netconfigurationv2-0/


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -