In a VB.Net project, you can use the Settings tab of the properties page to define application settings. To reference the settings in code, you use the syntax My.Settings.SettingName in VB.
On the Settings tab, you get to choose the Access Modifier. It may be "Friend" or "Public". Presumably, when you choose "Public", you are making the settings accessible to other assemblies. However, once "Public" is chosen, I can't figure out the syntax to reference the settings of one project from another. In fact, I can't observe any difference between using "Internal" vs. "Public" as the access modifier.
My question: Does choosing "Public" as the access modifier make settings accessible to other assemblies? If so, what is the syntax to reference the settings from other assemblies? If not, what does "Public" do?
User-scope settings are stored in the user's appdata folder. Application-scope settings are stored in C:\Users\My Name\AppData\Local\My_Company\. If your settings file doesn't contain any Application-scope settings, you won't have a company folder.
Settings. settings is located in the My Project folder for Visual Basic projects and in the Properties folder for Visual C# projects. The Project Designer then searches for other settings files in the project's root folder. Therefore, you should put your custom settings file there.
Application settings enables developers to save state in their application using very little custom code, and is a replacement for dynamic properties in previous versions of the . NET Framework.
You are mixing things up rather badly. A setting doesn't have a accessibility modifier, they are always public. However, in a Winforms app, you indeed have a "Application settings" property in the Properties window for a control. Right at the top. And a Modifier property. The latter is Friend by default in a VB.NET project, Private in a C# app. That determines the accessibility of the control variable, not the setting.
Yes, My.Settings gives you access to the setting that stores the control property value. But that's where the good news ends. You should always set the Scope of the setting in the settings designer to User. So that the value can be saved and restored when your program starts back up.
Settings with User scope are stored in a file that's hard to find back. The typical path of such a file is C:\Users\hpassant\AppData\Local\WindowsFormsApplication1\WindowsFormsApplication1._Url_2acx4ldi2zmg42elj3eyqq0snhqco4qe\1.0.0.0
The first part is me, the current user of my laptop. The bizarro part of the path name is a hash, a value that's unique for the application name and version. And probably something else like the phase of the moon when I compiled the app. The algorithm to compute that hash isn't documented. Just that it will be unique to my app and cannot be stomped on by another app.
And that's the rub, one app cannot find the user scoped settings for another app. You'll have to give up on using settings if that's important to you. And replace it with, say, an XmlDocument in a well known location.
I was looking for the same thing, so this it :
In C# :
[Namespace].Properties.Settings.Default.[SettingName]
In VB :
[Namespace].My.MySettings.Default.[SettingName]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With