views:

181

answers:

1

I recently checked out a large C# code base that I will be doing some work with, and converted the project(s) from VS2005 to VS2008. On building the solution, I seem to have generated a bunch of designer.cs files that do not belong there. I am now getting class re-declared errors. Note the designer.cs (and the associated resx files) have been generatated from classes that are just plain old C# classes, that should not have a designer attached at all.

I can delete these files and that fixes the problem, the issue is I have 500+ of these (from a code base of approx 14000 files) so this is going to be a painful process to work out the false ones and delete. More importantly I want to know why / how this happened.

Any ideas?

+2  A: 

Open up the .csproj file in a text editor - it's just XML and the format is relatively simple. Files that should have designers have an additional entry:

<Compile Include="MyForm.cs">
  <SubType>Form</SubType>
</Compile>
<Compile Include="MyForm.Designer.cs">
  <DependentUpon>MyForm.cs</DependentUpon>
</Compile>

If there's nothing readily apparent create a new VS2008 project and add some dummy classes of the same types as the ones you're having issues with. You can look at that new project's .csproj file as a reference for how your files should appear.

Keith
Thx, this would have been useful last month, this is pretty much what I ended up doing. I ended up writing a small app to generate a new proj file and (touch wood) it's been fine ever since. I still have no idea why it did what it did, which I admit gnaws away at me.
Tim Jarvis