Add Custom Data Type / Structure to My.Settings in VB.NET / WPF
During the work of a new Coretech SCCM Manager GUI in WPF, i ran in to some problems with My.Settings.
I have used My.Settings for all settings in the Utility, and are using my own structures for the combo-box value and others.
The problem is that i could not create a setting, that contained my own structure instead of a system data type.
I simply could not select it in the list:
I tried to use the browse function, but no luck.
I have searched the net for ages, trying to find a solution, but never found one.
This problem can occur in both Windows Forms And Windows Presentation Foundation (WPF) projects
After while i figured out how to do it:
1. Open the Settings.Designer.vb file
2. If you are working in an WPF project, you cannot select the code file behind the GUI for the settings. Therefore you have to go to the Project folder and open the file itself in \ProjectFolder\My Project\
3. Now copy one of the properties already in there:
-
_
-
Public Property OSDEnabled() As String
-
Get
-
Return CType(Me("OSDEnabled"),String)
-
End Get
-
Set
-
Me("OSDEnabled") = value
-
End Set
-
End Property
4. Change the new copy to your custom datatype, in my case it was my “Definitions” structure class
-
_
-
Public Property OSDCollection() As Definitions
-
Get
-
Return CType(Me("OSDCollection"), Definitions)
-
End Get
-
Set(ByVal value As Definitions)
-
Me("OSDCollection") = Value
-
End Set
-
End Property
5. Now it should be working, but the GUI in Visual Studio still does not show the new data type, but luckily this can be fixed!
6. Open Settings.Settings file in the same folder
7. Copy one of the old settings and change it to the new data type (just like you did before).
Copy one of the other settings:
-
<Setting Name="SWCollectionID" Type="System.String" Scope="User">
-
<Value Profile="(Default)" />
-
</Setting>
Change it to your new type:
-
<Setting Name="OSDCollection" Type="Coretech_Application_Creator.Definitions" Scope="User">
-
<Value Profile="(Default)" />
-
</Setting>
8. Now everything should be working and you data type has appeared in the dropdown list in Visual Studio.
I hope this small article is helpful.
P.S. I was working in Visual Studio 2008, but i think it is possible to do the same in 2005.
- Jakob

Seth:
Jakob,
Thank you for the article. Is there anything special that needs to be done in the class/type I am creating? I have followed your instructions but the data type does not show up for me. The only step I could not follow was the last step where I change something in the Settings.settings file. I do not see the same thing you see.
27th April 2009, 16:04Jakob Gottlieb Svendsen:
Hello Seth.
I am sorry, but this post was curreupted by an update.
that is why you did not see the same.
i have updated the post now, i hope it helps.
- Jakob
28th April 2009, 09:15Fatima:
hello Seth.
3rd August 2009, 11:45What if i am using c#. what i have to do? Because its been long i am trying to do this.
-Fatima
Jakob:
Hello Fatima
You can do almost the same in C#.
It is the same files (they are called .cs instead of .vb).
The syntax is ofcause a little bit different, but the method is exactly the same.
Copy an existing settings to a new one in Settings.Designer.cs
and do the same in Settings.Settings.
Remember to open settings.settings in a text editor, instead of the internal settigns designer. (Use Open With.. in VS)
I hope this helps
- Jakob
3rd August 2009, 11:54Anon-E-Moose:
just fyi, you can simply modify the settings.settings file with the xml editor built into visual studio, and the changes will reflect accordingly in settings.designer, without you having to edit both files
23rd October 2009, 06:32Yaiza:
Thank you very much!!! I was struggled with the very same problem and it was great to find a solution.
4th December 2009, 19:06Ignacio Soler:
Thanks a lot. A very valuable information.
I just can not understand why the Browse function does not work.
15th December 2009, 19:07Michael L. Long:
Excellent post thank you. It would seem to me Microsoft could add functionality to its designer to parse project types that are serializable / provide their own type converters, since those are the 2 main requirements (either or) as far as I know for a serializable property in settings. But that is simply standard to have a class serialize anyway so nothing new there, it’s just not automated. Maybe in a future build?
Anyway, thanks again. Simple and elegant solution and opens up the settings to be a lot more robust now.
31st January 2010, 20:10polygon:
Actualy if the browse does not work, you can just write the class name including namespace into the text box in the browse dialog. It worked for me.
3rd February 2010, 16:19What didn’t work is the serialization of this selected class. No matter that it was marked as serializable.