Unrecognized configuration section userSettings.

Ok so you might find this interesting. I was changing one of my dot net programs lately to no longer rely on user settings. Once I deleted all user settings, I received the following error: “Unrecognized configuration section userSettings”.
The solution to this is to load the user.config file into notepad and delete the entire userSettings section from the file.  Then rebuild your program and it will work again.

Closing a Form Via the Red X

So someone posed this question to me. How do you cancel the close event on the form. This usually occurs when the user clicks the “red x” button on the form.
Here is what you do:
Private Sub dialog_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim dlgRes As Windows.Forms.DialogResult
dlgRes = MessageBox.Show(“Are you sure you wish to exit?”, “Closing”, MessageBoxButtons.YesNo, MessageBoxIcon.Information)
If dlgRes = Windows.Forms.DialogResult.Yes Then
Me.DialogResult = Windows.Forms.DialogResult.Yes
e.Cancel = False
Else
e.Cancel = True
End If
End Sub
Notice this is for the FormClosing event. This event uses a special set of event arguments called the FormClosingEventArgs. There is a property you can set that will cancel the close process named cancel.
The reason I am posting this is that while this seems so very obvious, it is suprisingly difficult to find this information for a new programmer so hopefully this will get tagged more appropriately in Google’s search engine.

Dot Net User Settings Vs Application Settings

Application and user settings in .Net are very simple to take advantage of. But how are they different?
Application settings are stored in the applications config file (XML document). Application settings cannot be changed while the program is running. So if you make a change in the config file while the program is running those changes will not be reflected until you restart the program. As an example, connection strings are a great thing to save here.
User settings are initially stored in the config file. The first time the program gets run it takes the values in the config file and loads them into a memory block for the program. Once you close the program all settings that were changed while the program was running are then saved in this block of memory. You can also call the method My.Settings.Saver() which will save the settings prior to the termination of the program. Great things to save in this are object that the user can manipulate and you want to save that data when they leave the program.
You might not believe me with the user settings but try it out yourself. Create a small project that saves some settings to a user setting. Then open the program in your favorite hex editor. Search for the setting that you saved, you will find it!

Error MSB3482: SignTool reported an error ‘Keyset does not exist’.

So I got this today: error MSB3482: SignTool reported an error ‘Keyset does not exist’. I was trying to publish a project in Visual Studio 2005. Here is the resolution:
Right click the ClickOnce key marked with the PFX extension in your projects folder, install it and try to publish again.
The cause apparently was that I changed the configuration of the compiling. Changing them back to the original state did not work because the damage was done.
Let me know if this helps!

Visual Studio 2005 Tip of the Day – Class Diagram

I just have a really brief entry for today. In my continued efforts of self-improvement, I have stumbled upon a rather interesting feature in VS that I never knew (or bothered to look at). For some developers, they need to visualize what they are doing in one way or another. Well the good people at Microsoft have developed a GUI for creating classes called Class Diagram.

Right mouse click on your solution in the Solution Explorer and select Class Diagram. In there you will discover that you will be able to create the shells of your classes very simply and quickly. You can add methods, background fields, properties to new or existing classes you have created. In each of these you can include parameters and comments.

Once you include some code in the classes, you can even test the results with Test Bench. Basically you can enter values into the parameters of functions and see the output, without even writing the old main function and running through test case after test case. You still might want to do that anyway, so you can repeat your tests.

Well that is it for now!