Solved the Visual Studio code generation issue

Yesterday I wrote about an issue with a Visual Stud io 2005 Smart Device projects, which were moved to Visual Studio 2008.

Since creating a new project of that type in VS 2008 creates properties instead of public fields there have to be differences in the project description (*.vbproj for a project). To look for differences I like WinMerge most. So I launched it and compared a fresh VS2008 project f ile to the upgraded one.

There were many differences in both file. Because comparing both files alone did not help, I investigated a bit in how the code was generated. One evidence was the comment This source code was auto-generated by Microsoft.CompactFramework.Design.Data, Version 2.0.50727.3053.

Visual Studio uses this dll (located in %programfiles%\Microsoft Visual Studio 9 .0\common7\ide) to generate the proxy code. There is almost no info available on this assembly, therefore I had to start my favorite toy: Red Gate's Reflector.

The class DeviceDiscoCodeGenerator is responsible for generating the code using standard CodeDom techniques. In CodeDom you can specify CodeGenerationOptions as flags to specify how primitive types are represented (as fields or as properties). The flag I was looking for is GenerateProperies. And indeed, this flag is set in GenerateCode method guarded by an if statement. The if statement evaluates a build property (FileUpgradeFlags). Looking back in the project file (*.vbproj), there was an empty FileUpgradeFlags tag:


To set the flag I had to remove this entry. After doing a "Update Webreference" in Visual Studio, CodeDom generated the properties as expected!

Louis Haußknecht

Software developer, tech enthusiast.

Overath, Germany