MVC4 on .Net 4.5

182 views
Skip to first unread message

Stephen Price

unread,
Nov 13, 2012, 11:57:55 PM11/13/12
to ozalt...@googlegroups.com
Hey all,

I'm working on a website (and learning MVC4 in the process) and noticed its on .Net 4 not 4.5. I recall a the time azure not supporting 4.5 but saw the recent announcement that it now does.

When I switch my app to 4.5 I get a bunch of ambiguous references. 
ie on the Compare attribute below;

        [DataType(DataType.Password)]
        [Display(Name = "Confirm password")]
        [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
        public string ConfirmPassword { get; set; }

I had a bit of a look around but couldn't find any simple "do this" type tutorials or anything to help convert. Should I upgrade it to 4.5? I usually run the latest where I can as I don't like missing out on the latest bugs. 

cheers,
Stephen

Michael Minutillo

unread,
Nov 14, 2012, 4:29:04 AM11/14/12
to ozalt...@googlegroups.com
Hi Stephen,

There are 2 classes with the same name "CompareAttribute" and they are in different namespaces that are both referenced in using-statements in your file (System.ComponentModel.DataAnnotations.CompareAttribute [new in .NET 4.5] and System.Web.Mvc.CompareAttribute [the one you were using before the upgrade]). You can replace it with the full reference:

[System.Web.Mvc.Compare(...)]

or you can drop in a using statement like this:

using CompareAttribute = System.Web.Mvc.CompareAttribute;

Regards,
Mike


Michael M. Minutillo
Indiscriminate Information Sponge
http://codermike.com



--
You received this message because you are subscribed to the "ozaltdotnet" group.
To post: send an email to ozalt...@googlegroups.com
To unsubscribe: send an email to ozaltdotnet...@googlegroups.com
For more options, visit this group at
http://groups.google.com.au/group/ozaltdotnet?hl=en-GB
 
Find us on the web at http://ozalt.net

Stephen Price

unread,
Nov 14, 2012, 4:32:34 AM11/14/12
to ozalt...@googlegroups.com
Yep, figured that much out. Wasnt sure which one is the right one to use tho...

thanks oh yea spongeful one.
Reply all
Reply to author
Forward
0 new messages