[dba-VB] Application settings

jwcolby jwcolby at colbyconsulting.com
Mon Dec 7 07:56:31 CST 2009


OK, I am trying to reference

Properties.Settings.Default["ServerName"].ToString() and get the error

'System.Windows.Forms.PropertyStore' does not contain a definition for 'Settings' and no extension 
method 'Settings' accepting a first argument of type 'System.Windows.Forms.PropertyStore' could be 
found (are you missing a using directive or an assembly reference?)


John W. Colby
www.ColbyConsulting.com


Shamil Salakhetdinov wrote:
> Hi Gustav,
> 
> You can set 
> 
> Properties.Settings.Default.{{PropertyName}} = {{SomeValue}};
> 
> and save settings having "User" scope:
> 
> Properties.Settings.Default.Save();    
> 
> And they are saved not in {{ApplicationExecutableFileName}}.config, which
> you deliver with you app's executable but anywhere else on your system -
> probably somewhere in user's Application Settings - standard windows folder.
> I have never had time to find out where settings are saved. Anybody?
> 
> Recap:
> 
> - settings are loaded from {{ApplicationExecutableFileName}}.config when you
> deliver you application, and it runs first time;
> - as soon as you save "User" scope settings they are saved in and loaded
> from {{UnknownPlace}};
> - if you move your application files into another folder on the same system
> the settings are again loaded on first run from
> {{ApplicationExecutableFileName}};
> - ...
> 
> That looks confusing a bit but it's how it works...
> 
> You can click "Learn more about application settings..." on top right of
> VS2008 application settings window available by Solution Explorer -> Project
> name -> Right-Click -> Settings...
> 
> But if you wanted to have rather complicated structure of your application
> settings file then better use your own custom XML files, which can be loaded
> from/saved to files many ways without almost any coding...
> 
> Thank you.
> 
> --
> Shamil
> 
> 
> -----Original Message-----
> From: dba-vb-bounces at databaseadvisors.com
> [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
> Sent: Friday, December 04, 2009 8:25 PM
> To: dba-vb at databaseadvisors.com
> Subject: Re: [dba-VB] Application settings
> 
> Hi John
> 
> Shamil is right, but that method is for reading only.
> Please note that the Properties' collection object is read-only, thus it
> takes quite a few steps to add a property:
> 
> http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/c52b4fc6-
> 66be-44ce-8a65-ab548f6f4f04
> 
> I have not used this as I haven't had any need to add properties on the fly.
> Reading and writing was fine for me, and new properties I added manually.
> 
> You may find it much easier and perhaps more convenient to just have a
> dataset which you read and write from/to an XML-file. I've posted code for
> this before.
> 
> /gustav
> 
> 
>>>> jwcolby at colbyconsulting.com 04-12-2009 17:33 >>>
> Under the project is a properties object.  Double click that and an entire
> multi-tabbed dialog opens.
> 
> Click the settings tab.  There you will see a form where you can enter name,
> type, scope, value.
> 
> As far as I can tell this is a place where I (the developer) can create
> settings that my program 
> will use and manipulate, settings (for example) to tell my program the name
> of the SQL Server 
> instance to use in a connection string, the name of my control database
> where I store my stored 
> procedures and UDFs.  Stuff like that.  Stuff that I am currently hard
> coding, but which really 
> should be in a settings tab so that I don't have to remember where that
> constant is in code, I can 
> just go to the settings tab to change.
> 
> My expectation is that there is an object somewhere in the .net namespace
> that allows you to do 
> something like "Something.Somethingelse.Settings["MyServerName"]...." to
> access these things.
> 
> I expect to be able to create new ones, edit existing ones, delete them etc
> from a .Net object.  I 
> am looking for that .Net syntax that allows me to do this from code.
> 
> John W. Colby
> www.ColbyConsulting.com 
> 
> <<< snip >>>
>  
> 
> __________ Information from ESET NOD32 Antivirus, version of virus signature
> database 4661 (20091204) __________
> 
> The message was checked by ESET NOD32 Antivirus.
> 
> http://www.esetnod32.ru
>  
> 
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
> 
> 



More information about the dba-VB mailing list