我的应用程序Config类没有保存 [英] My app Config class not saving

查看:66
本文介绍了我的应用程序Config类没有保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Imports System.Configuration

Imports System.Reflection





公共类AppConfig



   私有_config作为配置

   私人设置为AppSettingsSection



    Public Function GetProperty(propertyName As String)As String

       返回_settings.Settings.Item(propertyName).Value

   结束功能



    Public Sub SetProperty(propertyName As String,propertyValue As String)

        _settings.Settings.Item(propertyName).Value = propertyValue

   结束点¥


    Public Sub New()

        _config = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly()。Location)

        _settings = _config.AppSettings

   结束点¥


   受保护的覆盖Sub Finalize()

        MyBase.Finalize()

        _config.Save(ConfigurationSaveMode.Modified)

   结束点¥


结束等级




解决方案

为什么这不起作用



Imports System.Configuration
Imports System.Reflection


Public Class AppConfig

    Private _config As Configuration
    Private _settings As AppSettingsSection

    Public Function GetProperty(propertyName As String) As String
        Return _settings.Settings.Item(propertyName).Value
    End Function

    Public Sub SetProperty(propertyName As String, propertyValue As String)
        _settings.Settings.Item(propertyName).Value = propertyValue
    End Sub

    Public Sub New()
        _config = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location)
        _settings = _config.AppSettings
    End Sub

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
        _config.Save(ConfigurationSaveMode.Modified)
    End Sub

End Class

解决方案

why is this not working


这篇关于我的应用程序Config类没有保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆