473,545 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

My.Settings object set setting by name?

I know there must be a way to do this... in .NET 2.0?

I have a situation where I know the name of the setting, and want to
pass it into a function, and set or get the corresponding setting.

The following is find, but a pain if you have lots of settings to do in
one go...

My.Setting.Dach shund=1000
Dim theSetting As Integer=My.Sett ing.Dachshund

Looking for some thing like...

Sub SetSetting(ByVa l theName As String, ByVal theValue As Object)

My.Setting(theN ame) = theValue

End Sub

Function GetSetting(ByVa l theName As String) As Object

Return (My.Settings(th eName))

End Function

I figure i could call My.Setting.<Met hod>? Via Invoke by name? But I
am not a Invoke guru?

Any help greatly desired, Thanks

May 6 '06 #1
1 2933
On 2006-05-06, Dachshund Digital <Sc*******@adel phia.net> wrote:
I know there must be a way to do this... in .NET 2.0?

I have a situation where I know the name of the setting, and want to
pass it into a function, and set or get the corresponding setting.

The following is find, but a pain if you have lots of settings to do in
one go...

My.Setting.Dach shund=1000
Dim theSetting As Integer=My.Sett ing.Dachshund

Looking for some thing like...

Sub SetSetting(ByVa l theName As String, ByVal theValue As Object)

My.Setting(theN ame) = theValue
This is evil, but you could always do something like

My.MySettingsPr operty.Settings .Item(theName) = value
Rather than using undocumented names though, you'd probably be better
off saving a hashtable or NameValueCollec tion in My.Settings, then
accessing its members normally.

End Sub

Function GetSetting(ByVa l theName As String) As Object

Return (My.Settings(th eName))

End Function

I figure i could call My.Setting.<Met hod>? Via Invoke by name? But I
am not a Invoke guru?

Any help greatly desired, Thanks

May 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
16619
by: GS | last post by:
Hi, There is reference about accessing settings file in VB.NET but nothing about C#. How do I read settings in application settings file with C#? Thanks, G
10
3039
by: Chris Dunaway | last post by:
I have an .exe console project and a class library project as part of a solution. The .exe has an App.config file and I have used the Settings page to add some Application level settings. When I try to retrieve a setting using this code: //Method 1 string s = ConfigurationManager.AppSettings;
5
8369
by: Andy | last post by:
I need to write a VB.NET WinForms app. For this purpose I need to keep some settings of the application, like many other Windows applications do. The most obvious solution is to store settings in the XML file or registry. If it's an XML file, then I need the following: 1. Create XSD schema, and be able to validate XML file with the...
0
2820
by: =?Utf-8?B?UmljayBHbG9z?= | last post by:
For some unknown reason (user error?), I cannot get a NameValueCollection to persist in the app.config file. Unlike other settings, I cannot get the String Collection Editor GUI to allow my to add/edit any values for a setting with type NameValueCollection. Nor can I get a NameValueCollection to persist to the User Settings via code using...
6
2789
by: WT | last post by:
Hello, Using VS2005. I have an assembly library that can be called from a Web site asp.net application or from a winform application. From this library I need to retrieve a path using simply a key like 'libPath'. As far as winform and asp.net share the same common base class for settings, SettingsBase, how to manage this ? For winform...
5
8604
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The plan is to delivere different report.dlls with the main app. But it is essentially importent, that the reports and the app use the same settings.
2
1941
by: Robert Dufour | last post by:
Its easyb to change user leve settings but how do you change application level settings in code. Apparently it seems it can't be done. Duhhh. Anybody manage a workaround? Thanks for any help. Bob
2
10051
by: =?Utf-8?B?QWFyb24=?= | last post by:
I am trying to create dynamic settings in a .NET 2.0 C# application. I need to be able to store settings on the user, but I do not know how many settings are necessary at design time because the settings are determined by a business object that is loaded into the app of which there could be one or many. I would prefer to use the same...
0
8145
by: Lucky | last post by:
Hi guys, I've got a problem under reading settlings from App.config file. I've used System.Configuration to reach to the "User Settings" and "Application Settings" sections. the problem is now I'm not able read the property defined under this section. those are like this User Settings -Testing Application Settings -Test
0
7675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5997
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1902
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
726
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.