首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

C# 错误1’Settings': 成员名称不能与它们的封闭类型相同

2014-01-28 
本来是在一个Settings.settings 的 Settings.Designer.cs中想更改一个连接字符串为动态的 代码如下:C# code

本来是在一个Settings.settings 的 Settings.Designer.cs中想更改一个连接字符串为动态的

代码如下:

C# code
//------------------------------------------------------------------------------// <auto-generated>//     This code was generated by a tool.//     Runtime Version:2.0.50727.4927////     Changes to this file may cause incorrect behavior and will be lost if//     the code is regenerated.// </auto-generated>//------------------------------------------------------------------------------using Microsoft.Win32;namespace Common.Properties{    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase    {        string DataString = "";        //public void Settings()        //{        //    if (GetRegistData("ServerIP") != "")        //    {        //        DataString = GetRegistData("ServerIP");        //    }        //}        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));        public static Settings Default        {            get            {                return defaultInstance;            }        }        [global::System.Configuration.ApplicationScopedSettingAttribute()]        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]        [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]        [global::System.Configuration.DefaultSettingValueAttribute("Data Source=" + DataString + ";Initial Catalog=DB;Persist Security Info=True;Us" +            "er ID=sa;Password=sa")]        public string HighwayDBConnectionString        {            get            {                return ((string)(this["DBConnectionString"]));            }        }        //读取指定键路径的值        public static string GetRegistData(string name)        {            string registData = "";            try            {                RegistryKey hkml = Registry.LocalMachine;                RegistryKey regServerIP = hkml.OpenSubKey("SOFTWARE/YYDZ/Highway", true);                registData = regServerIP.GetValue(name).ToString();            }            catch            {                            }            return registData;        }    }}



我要怎么做啊,现在这样的话注释掉的代码:
 

C# code
  //public void Settings()        //{        //    if (GetRegistData("ServerIP") != "")        //    {        //        DataString = GetRegistData("ServerIP");        //    }        //}        

热点排行