Dan Byström’s Bwain

Blog without an interesting name

Archive for September, 2005

Visual Studio 2003 Workaround

Posted by Dan Byström on September 27, 2005

Now when we’re all anticipating Visual Studio 2005, it’s time for me to crank out a tip regarding Visual Studio 2003.

If it’s a tip concerning you depends on whether or not you’re among the unfortunate ones like me, who sometimes displeases VS in such a way that it decides to teach me a lesson – by turning most of my Forms and UserControls into regular classes so that they cannot be designed anymore!

If this hasn’t happened to you – you’re among the fortunate ones and I congratulate you. (God’s little pet, right!?)

When this disaster has struck me before I have either resumed from a backup and just moved the latest changed files back into my project, or I have tediously begun to copy the text of each damaged file to the clipboard and then deleted the file from the project, then adding a new one with the same name and finally pasting the code back into place. Not very fun at all.

Now I just discovered that there is a much easier way to recover! I just open the .csproj file in Notepad. There I’ll find XML tags like these:

<File
    RelPath = "controls\vdCalendar.cs"
    SubType = "Code"
    BuildAction = "Compile"
/>
<File
    RelPath = "controls\vdCalendar.resx"
    DependentUpon = "vdCalendar.cs"
    BuildAction = "EmbeddedResource"
/>
<File
    RelPath = "dialogs\FAbout.cs"
    SubType = "Code"
    BuildAction = "Compile"
/>
<File
    RelPath = "dialogs\FAbout.resx"
    DependentUpon = "FAbout.cs"
    BuildAction = "EmbeddedResource"
/>

By walking through the list of files and changing each into the desired “SubType” it is much easier to recover:

<File
    RelPath = "controls\vdCalendar.cs"
    SubType = "UserControl"
    BuildAction = "Compile"
/>
<File
    RelPath = "controls\vdCalendar.resx"
    DependentUpon = "vdCalendar.cs"
    BuildAction = "EmbeddedResource"
/>
<File
    RelPath = "dialogs\FAbout.cs"
    SubType = "Form"
    BuildAction = "Compile"
/>
<File
    RelPath = "dialogs\FAbout.resx"
    DependentUpon = "FAbout.cs"
    BuildAction = "EmbeddedResource"
/>

But then again, I may be the only person alive who can annoy Visual Studio 2003 to this extent in the first place!

Posted in Programming | Leave a Comment »