Archive for the 'Visual Studio' Category

Loading Individual Designer Default Values into Visual Studio .NET Settings

The VS.NET Settings designer creates an ApplicationSettingsBase Settings class in Settings.Designer.cs (and optionally Settings.cs).  The default values from the designer are saved in app.config and are loaded into the Settings.Default singleton at runtime.

So, now you have a button on a properties page that says ‘Reset to Factory Defaults’ where you want to reload the designer default values back into your properties.  If you want do this for all property values you can just use Settings.Default.Reset(). But what if you only want to reset a subset of your properties? 

There may be a better way to do this, but I couldn’t find one.  The following code does the job and will hopefully save someone from having to reinvent this wheel.

The ResetToFactoryDefaults method takes a collection of SettingsPropertys and uses the DefaultValue string to reset the value. Most value types (string, int, bool, etc.) worked with the TypeConverter, but the StringCollection class is not supported so the XML string has to be deserialized manually.

These helper methods show how just selected (and all) properties can be reset.

This code was developed with VS 2005, but should also work in VS 2008.

SolutionZipper Updated

I’ve updated my SolutionZipper source and installer to version 1.3 on CodeProject. Here are the changes:

  • Fixed a bug that was causing SZ to fail during the “Handle external projects” phase.
  • Ignore VC++ Intellisense Database files, i.e. *.ncb.
  • Ignore hidden files and folders.

I originally wrote this last year as simply a convenience function. Even though I use a source code control system (Subversion) at work, I still need a quick way to snapshot and backup my personal projects at home.

I recently started a solution that included a C++ project and noticed some problems. First was that there was no need to backup the VC++ Intellisense database file. The second problem might be related to one of these:

  • Microsoft Visual Studio 2005 Professional Edition – ENU Service Pack 1 (KB926601)
  • Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP
  • Microsoft ASP.NET 2.0 AJAX Extensions 1.0

I don’t know which one caused the problem, but after one of these was installed VS2005 had project list items that were not file system based — a project called <MiscFiles>? Anyway, this caused the search for external projects to fail.

There was a request to ignore Subversion (.svn) directories. This was a good idea so I just ignore all hidden directories and files. This also means that VS Solution User Option files (.suo) are not included in the zip file.

Subscribe

Categories

Twitter Updates