Reputation: 11
I recently downloaded/installed the WATK. I also signed up for a free azure trial. Went through the lab "Building and Publishing ASP.NET Applications with Windows Azure Web Sites and Visual Studio 2012". I was 80% complete when I found out that kit is using .NET 4.5 and the Azure sites will only accept .NET framework 4.0. If I change the lab property configuration, to 4.0, it will not compile. The culprit code is:
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
Upvotes: 1
Views: 979
Reputation: 24895
The issue you're having here is because the CompareAttribute attribute is both available in the 4.5 version of the DataAnnotations assembly and in the System.Web.Mvc assembly. Since you started the project in 4.5 you probably based your code on System.ComponentModel.DataAnnotations.CompareAttribute (.NET 4.5).
By switching to the System.Web.Mvc.CompareAttribute you can fix the error:
[System.Web.Mvc.CompareAttribute("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
[System.Web.Mvc.CompareAttribute("Password", ErrorMessage = "The password and confirmation password do not match.")]
(Adding a using statement for System.Web.Mvc will also fix the issue)
Upvotes: 2
Reputation: 23754
That lab starts with File>New Project so it isn't really tied to a framework until you do File>New. Check your default framework on the dialog, I suspect it's 4.5
As for changing it back to 4.0 after the fact, I didn't try that but perhaps there's other code generated that's not compatible. The two lines you refer to though are definitely part of the generated code and don't cause a problem in my case.
What is the associated compilation error?
Upvotes: 1