Visual C# Express gotcha
I am used to full blown Visual Studio 2005 but I decided that I'd play with Visual C# Express so I could better get a feel for that IDE since this is the environment for XNA Express.
Just so you all know, when you create a project in C# Express it doesn't get saved to disk until you explicitly tell it to save or close the project. Amazingly even if you compile and run the new project it still won't be saved to disk.
The upshot of this is that if the IDE crashes or gets terminated unexpectedly there doesn't seem to be any way to recover the project or the files you were editing. Twice I ended up losing the entire project I was working on because of this. I searched the entire disk to try and find my files and couldn't.
The workaround is simple enough though - make sure you save the project immediately after you create it and make sure you habitually save the files you are editing at opportune moments.
Actually, VC# Express saves these files to a temporary directory, so if the IDE crashes I think you can go there to recover them.
On my laptop, these apparently go to:
C:\Documents and Settings\Erik\Local Settings\Application Data\Temporary Projects\ProjectName
By default it saves "AutoRecover" data every 5 minutes, so you shouldn't lose your work in the case the IDE crashes. You can also go into the Options and change the default behavior to have it save the project on creation.
1. Go to Tools | Options
2. Click the "Show All Settings" check box
3. Select Projects and Solutions
4. On the right, make sure the "Save new projects when created" option is checked.
5. Click OK.
Hmmm, well I do have the "Temporary Projects" folder but there is nothing in it 
I found out why...
1. Launch C# Express and create a new project
2. Forcibly terminate C# Express using TaskManager or taskkill
3. Notice that at this point the "Temporary Projects" folder does still contain the project you just created
4. Launch C# Express
5. Notice that when C# Express launches the first thing it does is delete the "Temporary Projects" folder 
Thanks for the tip I would have run in to that problem, I was getting used to not saving when I compile. I was kinda hopeing that XNA would install like it is another lauguge if you have VS2005.
So if you get C# express and VB express they are 2 completly sepreate programs?
aka_Big_Wurm wrote: |
| So if you get C# express and VB express they are 2 completly sepreate programs? |
|
yes, different products.
you can purchase the full version of Visual Studio 2005 which allows you to do more and have VB.NET, C#, VC++.NET included all in one environment
Did you also know that when you write a letter in MS Word, even if you print the letter, you can close Word and lose your document? Unbelievable! </sarc>
It's hardly a knock against C#. Just save your work already.
- MrSock
Actually if you close Microsoft Word it asks you if you wish to save your document, even if you have printed it. The same is true with C# Express. But that aside...
This was by no means a slur against C# or the C# Express IDE. The point I was trying to make here is that C# Express by default has a different behavior from Visual Studio 2005. By default, in C# Express projects are created in a special hidden folder called "Temporary Projects" whereas in VS 2005 you must choose the location of the project at creation time.
In C# Express this behavior is only an issue if it crashes, is terminated or power is lost to the machine before you have had chance to save the project to it's permanent home. In fact if you are using this "Temporary Projects" mode you can save the .CS files in your project all you like but you still have the potential to lose them until you finally save the entire project since following a crash C# Express will silently delete the "Temporary Projects" folder the next time it is started.
For those of us on the forum who are used to the default Visual Studio 2005 project creation model it is useful to document the difference in behavior when switching to Visual C# Express. It was pointed out that fortunately there is an option to turn off the use of the temporary project folder in C# Express which makes the problem a non-issue (assuming you know about the option).
There is an option in both VS2005 and VSExpress to save new projects.
The option is in 'Projects and Solutions/General' and is 'Save new projects when created'.
This should now save the project when it is created and when ever it is executed (from VS).
I believe that VS2005 acts the same way, but not sure if the default is for this option to be on (can't remeber turning it on in VS2005).
Hope this helps.