How to Databind ObservableCollection to a DataGrid using DataTemplate?

I’ve got an ASP.NET Web Site (v3.5) with an associated Visual Studio 2008 Web Site Deployment project (hence the MSBUILD forum). Everything builds correctly until I added a class to the site that has auto-implemented properties:

public class Address {
  public string Street1 {get; set; }
  public string City {get; set; }
  public string Country {get; set}

This causes the msbuild to fail claiming CS0501 errors: Address.Street1.get must declare a body because it is not marked abstract or extern. Having run msbuild /v:Detailed I can see that v2.0.50727/aspnet_compiler is being called to do the work for the website deployment (after the site itself is successfully compiled and merged). I realize that declaring the class Address in the “old” way (i.e. private members and full getters/setters) will workaround this particular problem…but I get the impression that the compiler MSBUILD is invoking is simply the wrong version.

Any thoughts would be most appreciated.

Hi,I have performed a test according to your description. But I cannot reproduce your problem if I choose .NET Framework 3.5 as the target framework. However, when I chose .NET Framework 2.0 as the target framework, I got the same issue as you said. I would like to suggest you check if you use the .NET Framework 3.5 as the target framework for your website project.Thanks,Rong-Chun ZhangPlease mark the replies as answers if they help and unmark if they don’t./

How do you specify the target framework for msbuild? In my csproj file, I’ve already specified v3.5. I’ve look through the list of command line parameters, for msbuild  but can’t find any obvious one. What else is needed?

Adding ToolsVersion=”3.5″ fixed it for me: