The blog has moved to a new address. The blog is now located at

Tuesday, August 29, 2006

Clean Sources

This Application does one thing. It adds an explorer shell menu to folders that when selected will recursively delete the contents of the bin, obj and setup folders. If you have a .NET project that you wish to share with some one, this is useful to remove the unnecessary stuff from the folder before you zip it up and send it off.

Download Clean Sources

Monday, August 28, 2006

Code Formatter Plugin for Windows Live Writer


  • The ability to format the code 'live'
  • The ability to wrap lines
  • The ability to change the background color
  • The ability to just quickly paste what's in the clipboard as code


Download Code Formatter Plugin


tags: , , ,

Sunday, August 20, 2006

Application Updater by Wilco Bauwer

This new application updater is a new application updater component which is customizable and supports both WebDAV and BITS . BITS allows you to let the application download updates in the background, which means users would practically not notice anything, since BITS will use unused bandwidth.

Add a reference to and implement the IAgent interface. Your IAgent implementation will be used for getting available updates and such.
When you've done that, you write your own download implementation in case you don't want to use WebDAV or BITS to download updates.
The next thing you got to do is initialize a new Updater, add eventhandlers, and that's basically all you got to do.
If you want to check for updates, you call the Refresh method on the Updater instance, when you've detected an update you call the Download method, and when you're done with updating and want to restart the application, you use the ApplyUpdate method.


Technorati Tags: 

Saturday, August 19, 2006

Threading in C# - By Joseph Albahari

Threading in C# An extensive article on multi-threading in C#. This tackles difficult issues such as thread safety, when to use Abort, Wait Handles vs Wait and Pulse, the implications of Apartment Threading in Windows Forms, using Thread Pooling, Synchronization Contexts, Memory Barriers and non-blocking synchronization constructs.

[Via Roy Osherove's Blog]

Friday, August 11, 2006

How can I prevent the SplitContainer from stealing focus?

The default behavior for the splitter is to take focus once selected. If you want the splitter to be movable without taking focus you can do one of two things:
Insert the following code in your project, and attach these events to all of the SplitContainers that you don't want stealing focus.

// Temp variable to store a previously focused control
private Control focused = null;
private void splitContainer_MouseDown(object sender, MouseEventArgs e)
// Get the focused control before the splitter is focused
focused = getFocused(this.Controls);
private Control getFocused(Control.ControlCollection controls)
foreach (Control c in controls)
if (c.Focused)
// Return the focused control
return c;
else if (c.ContainsFocus)
// If the focus is contained inside a control's children
// return the child
return getFocused(c.Controls);
// No control on the form has focus
return null;
private void splitContainer_MouseUp(object sender, MouseEventArgs e)
// If a previous control had focus
if (focused != null)
// Return focus and clear the temp variable for
// garbage collection
focused = null;

Technorati : , , ,

Why isn’t the splitter visible when I run my application?

If the splitter is not distinguishable from the rest of the split container, it is due to the SplitContainerPanels having the same background color as the splitter, and the BorderStyle being set to None. To make the splitter easily recognizable, change the BackColor for the SplitContainerPanels, or set the SplitContainer's BorderStyle.

Technorati : , ,

How do I select the SplitContainer at design time?

If you want to select a SplitContainer control at design time, click on the splitter. If you click on either of the SplitContainerPanels, you will select them instead. Also you can use the drop down menu in the property grid to select the SplitContainer by name. Finally you can use the Document Outline to select the SplitContainer and control the Z-order of the controls within it.

Technorati : , ,

Client Settings FAQ

How do I persist application settings in the registry?

For information on using the registry for settings, see the following SDK sample:

How do I use a Web service client to retrieve application settings?

For information on using the a Web service for settings, see the following SDK sample:

Technorati : , ,

How do I get the class to serialize correctly?

While most common types can be serialized in one of two ways listed above, there are some types that may not. In such cases, you have a few different options:

  • Implement a TypeConverter for the type that can convert to and from string. The implementation can use a suitable serialization mechanism like one of the formatters/serializers that ship in the Framework or any custom mechanism you wish. You can then specify this converter on the type itself or on the property in your settings class.

  • Specify a particular SettingsSerializeAs enum value using a SettingsSerializeAsAttribute. For example, if you wish to serialize a setting in binary format, simply specify SettingsSerializeAs.Binary.

Technorati : , ,

Is there any way to change or customize the path of the user.config file?

The LocalFileSettingsProvider does not provide a way to change the files in which settings are stored.

Note: The provider itself doesn't determine the config file locations in the first place - it is the configuration system.

If you need to store the settings in a different location for some reason, the recommended way is to write your own SettingsProvider. This is fairly simple to implement and you can find samples in the .NET 2.0 SDK that show how to do this. Keep in mind however that you may run into the same isolation issues mentioned above.

Technorati : , ,

How can I get the user.config file path programmatically in a non-Clickonce app?

If you want to get to the path programmatically, you can do it using the Configuration Management API. For example, here is how you can get the local user.config file path:

Note: You need to add a reference to System.Configuration.dll

Configuration config =
Console.WriteLine("Local user config path: {0}", config.FilePath);

Technorati : , ,

Why is there a version number in the user.config path?

There are a couple of reasons why the user.config path is version sensitive:

  • To support side-by-side deployment of different versions of an application (you can do this with Clickonce, for example). It is possible for different versions of the application to have different settings saved out.

  • When you upgrade an application, the settings class may have been altered and may not be compatible with what's saved out, which can lead to problems.

Technorati : , ,

Why is the user.config path so obscure?

The path construction algorithm has to meet certain rigorous requirements in terms of security, isolation and robustness. While we tried to make the path as easily discoverable as possible by making use of friendly, application supplied strings, it is not possible to keep the path totally simple without running into issues like collisions with other apps, spoofing etc.

Technorati : , ,

Where is the user.config file located in a non-Clickonce app?

The path of the user.config files is structured as follows:
<Profile Directory>\<Company Name>\<App Name>_<Evidence Type>_<Evidence Hash>\<Version>\user.config


  • <Profile Directory> - is either the roaming profile directory or the local one. Settings are stored by default in the local user.config file. To store a setting in the roaming user.config file, you need to mark the setting with the SettingsManageabilityAttribute with SettingsManageability set to Roaming.

  • <Company Name> - is typically the string specified by the AssemblyCompanyAttribute (with the caveat that the string is escaped and truncated as necessary, and if not specified on the assembly, we have a fallback procedure).

  • <App Name> - is typically the string specified by the AssemblyProductAttribute (same caveats as for company name).

  • <Evidence Type> and <Evidence Hash> - information derived from the app domain evidence to provide proper app domain and assembly isolation.

  • <Version> - typically the version specified in the AssemblyVersionAttribute. This is required to isolate different versions of the app deployed side by side.

Note: The file name is always simply 'user.config'

Technorati : , ,

Why can't I change application scoped settings at runtime?

Application scoped settings are essentially read only from the application's point of view, and aren't meant to be changed by users, but rather only the administrator. An additional reason for this has to do with how the default SettingsProvider stores settings. Application scoped settings are stored in the exe configuration file, and user scoped settings are stored in user.config files located in the user data path. Generally, exe config files should not be written to at runtime by the application, since the user may not have access to them. In addition, it is normally not a good idea for a user to change a file that affects every other user of the application.

Technorati : , , ,

What is the difference between application scoped and user scoped settings?

There are generally two main types of settings that applications want to store:

  1. Static data like connection strings and web references that don't change often, but should still be possible for an admin to change.

  2. User preferences and customization settings that can change at any time.

Application scoped settings are useful in scenario (1) and user scoped settings are useful in scenario (2).