AssemblyBinding BindingRedirect not working for MVC4 app with T4MVCExtensions

陌路散爱 提交于 2019-11-29 07:30:15

I had a very similar assembly binding issue, after manually upgrading a set of MVC3 projects to MVC4. Despite having the assembly binding elements in web.config, I was getting errors similar to T4MVC errors but from the Telerik MVC Extensions.

The Fusion Log viewer was useful as it confirmed that two versions of system.web.mvc were being loaded into the application domain.

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

So, the web.config was like this:

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

And after removing the namespace it looks like this:

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

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

To isolate, I would try creating a tiny dummy assembly that is built against MVC3 to see if it behaves similarly. There shouldn't be anything special about the T4MVC helper assembly.

Also, please look at my test project https://github.com/davidebbo/T4MVCSampleApp. This is an MVC4 project that uses the latest T4MVC, and it runs fine for me. Does it run for you?

If all else fails, if you can share a repro project (e.g. on github), I can try to take a look.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!