PROBLEMA: LER E SALVAR NO APP.CONFIG VB 2017

TRTNCG 24/08/2017 14:36:43
#475991
Olá Srs, Boa Tarde!

Bom estou tentando guardar as minhas configurações no App.Config, no entanto consigo ler, mas salvar, nem dá erro, executa só que não atualiza o App.Config

Para Ler:
[txt-color=#0000f0]My.Settings.coringa
txt_usuario.Text = (My.Settings.userdb)
txt_senha.Text = (My.Settings.passworddb)
[/txt-color]

Estrutura do App.config

<?xml version=[Ô]1.0[Ô] encoding=[Ô]utf-8[Ô]?>
<configuration>
<configSections>
<sectionGroup name=[Ô]applicationSettings[Ô] type=[Ô]System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089[Ô] >
<section name=[Ô]Vendas_Control.My.MySettings[Ô] type=[Ô]System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089[Ô] requirePermission=[Ô]false[Ô] />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version=[Ô]v4.0[Ô] sku=[Ô].NETFramework,Version=v4.6.1[Ô] />
</startup>
<system.data>
<DbProviderFactories>
<remove invariant=[Ô]FirebirdSql.Data.FirebirdClient[Ô] />
<add name=[Ô]FirebirdClient Data Provider[Ô] invariant=[Ô]FirebirdSql.Data.FirebirdClient[Ô] description=[Ô].NET Framework Data Provider for Firebird[Ô] type=[Ô]FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient[Ô] />
</DbProviderFactories>
</system.data>
<applicationSettings>
<Vendas_Control.My.MySettings>
<setting name=[Ô]userdb[Ô] serializeAs=[Ô]String[Ô]>
<value>1</value>
</setting>
<setting name=[Ô]passworddb[Ô] serializeAs=[Ô]String[Ô]>
<value>123</value>
</setting>
<setting name=[Ô]coringa[Ô] serializeAs=[Ô]String[Ô]>
<value>123456</value>
</setting>
</Vendas_Control.My.MySettings>
</applicationSettings>
</configuration>

Para Salvar:
[txt-color=#0000f0]My.Settings.userdb = usuariocriptografado --> AQUI DÁ ERRO DIZ QUE é SOMENTE LEITURA
My.Settings.Save()
My.Settings.Reload()
[/txt-color]

Como resolver isso?


TUNUSAT 25/08/2017 09:02:13
#475998
Resposta escolhida

TRTNCG,

Eu montei um exemplo aqui no VBMania....
... por favor, você poderia baixa-lo e testar?

=======================================================

Título: APP.CONFIG E CONNECTIONSTRINGS
Categoria: VB.NET :: Codigo Fonte :: Bancos de dados
Compatibilidade: Visual Studio 2010
Criado por: TUNUSAT
Tamanho: 15,83 KB
Data de postagem: 26/04/2014 18:18:07
Comentários: Exemplo da Microsoft usando o App.Config e o ConnectionStrings. Mudei o exemplo um pouco. Está feito em Console Application.

=======================================================

[][ô]s,
Tunusat.
TRTNCG 25/08/2017 14:01:23
#476022
TUNUSAT, muito obrigado pela dica, mas, lendo já estou normalmente o problema é que não consigo SALVAR ou atualizar no App.config, já tentei inúmeros códigos da internet e nada, você teria algum exemplo que tenha como salvar os dados no app.config?
TUNUSAT 25/08/2017 14:29:22
#476023
TRTNCG,

é ... salvar não, mas achei algumas coisas na internet...

====================================================================

https://stackoverflow.com/questions/25040243/how-to-save-changes-to-app-config-file-from-runtime-for-a-visual-studio-add-in

 Dim pluginAssemblyPath As String = Assembly.GetExecutingAssembly().Location
[ô]Dim configuration As Configuration = ConfigurationManager.OpenExeConfiguration(pluginAssemblyPath)
Dim test1 As String = configuration.AppSettings.Settings.Item([Ô]Key1[Ô]).Value

configuration.AppSettings.Settings.Item([Ô]Key1[Ô]).Value = [Ô]Is this thing on?[Ô]

Dim test3 As String = configuration.AppSettings.Settings.Item([Ô]Key1[Ô]).Value
configuration.AppSettings.SectionInformation.ForceSave = True
configuration.Save(ConfigurationSaveMode.Modified)
ConfigurationManager.RefreshSection([Ô]appSettings[Ô])


====================================================================

https://stackoverflow.com/questions/30361992/in-vb-net-how-do-i-save-changes-to-app-config

My.Settings.Save()


====================================================================

Easily Save and Retrieve Application and User Settings in VB.NET or C# Apps

http://www.dondraper.com/2011/01/easily-save-and-retrieve-application-and-user-settings-in-vb-net-or-c-apps/

====================================================================

VB.NET - Reading and writing app.config

http://www.neolisk.com/techblog/vbnet-read-write-appconfig

====================================================================

How to change value in app.config file in vb.net ?
Rate:

 Dim config As Configuration =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)

config.AppSettings.Settings([Ô]radbtnBrowseSLD[Ô]).Value = [Ô]newvalue[Ô]

config.Save(ConfigurationSaveMode.Modified)

ConfigurationManager.RefreshSection([Ô]appSettings[Ô])


https://www.codeproject.com/Questions/692054/How-to-change-value-in-app-config-file-in-vb-net

====================================================================

Read/Write App.Config File with .NET 2.0

https://www.codeproject.com/Articles/14744/Read-Write-App-Config-File-with-NET

====================================================================

[][ô]s,
Tunusat.
Tópico encerrado , respostas não são mais permitidas