Access资源文件设置

Access资源文件设置

本文介绍了SharpDevelop Access资源文件设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问通过SharpDevelop模板创建的设置文件(MySettings)中的设置:

I'm trying to access settings from a settings file(MySettings) that I have created through the SharpDevelop Template:

设置:

[global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("")]
        public string s_Username {
            get {
                return ((string)(this["s_Username"]));
            }
            set {
                this["s_Username"] = value;
            }
        }
    }

代码:

void MainFormLoad(object sender, EventArgs e)
    {

        MessageBox.Show(AdhesionCharting.Properties.MySettings.s_Username);

    }

错误:

'AdhesionCharting.Properties.MySettings'是一个'类型',在给定的上下文中无效

'AdhesionCharting.Properties.MySettings' is a 'type', which is not valid in the given context

推荐答案

如果查看MySettings.cs文件,您将看到该类不是静态的.有一个Default属性可以使用,它是静态的.因此,您的代码应更改为:

If you look at your MySettings.cs file you will see that the class is not static. There is a Default property which is static that can be used. So your code should be changed to be:

void MainFormLoad(object sender, EventArgs e)
{
    MessageBox.Show(AdhesionCharting.Properties.MySettings.Default.s_Username);
}

这篇关于SharpDevelop Access资源文件设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 02:06