MVC 5

Oct 21, 2013 at 11:58 AM
Hi there,

I tried to upgrade my web app over the weekend upgrading to the latest version of MVC. THe current Unity version doesn't seem to be compatible with MVC 5. Previously I used .SetDependencyResolver(new UnityContainer()) but the container constructor seems not to be available anymore and I recognized that it is located in a MVC4 namespace.
I'm I correct with that?

Regards,
Tassilo
Oct 21, 2013 at 2:56 PM
It should be compatible. By the current Unity version I assume you mean Unity 3.

I just upgraded from MVC 4 to MVC 5 following the instructions at How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API 2.

From your description of an MVC4 namespace I'm assuming you are using a third party library (not that there is anything wrong with that!); perhaps Unity.MVC4. Off the top of my head I can't say whether that library has any MVC 5 issues.

In my testing I used the Unity bootstrapper for ASP.NET MVC without the need to make any changes (besides the normal migration changes of updated assembly references and adding binding redirects).

In my case the code I'm using to register the dependency resolver is:
DependencyResolver.SetResolver(new UnityDependencyResolver(container));
I think this code is the same as other packages use.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Oct 21, 2013 at 8:32 PM
Hi, thank you Randy,

Yes, you may be right. I installed it via the NuGet package Manager in VS and didn't pay much Attention on what I was downloading. And sorry for the code. I was at work and couldn't remember the exact wording. But you understood me anyway :-) Ist exactly the same code I'm using. No idea why it couldn't resolve the constructor.
Thank you very much for the link. I think I'll give it another try.

Best regards,
Tassilo