我的应用程序中有两个程序集。 MyApplication.BO MyApplication.GUI

我为BO程序集配置了属性设置。

现在,当我尝试编译以下代码时:

public class MyApplicationInfo
{
 private string _nameOfTheUser;
 public string FullNameOfTheUser
 {
  get { return _nameOfTheUser; }
  set { _nameOfTheUser = value; }
 } 

 public void Save()
 {
  try
  {
   MyApplication.BO.Properties.Settings.Default.FullNameOfTheUser = this.FullNameOfTheUser;

   MyApplication.BO.Properties.Settings.Default.Save();
  }
  catch (Exception ex)
  {
   throw ex;
  }
 }
}

VS2005给出了以下编译错误:

  

错误1属性或索引器'MyApplication.BO.Properties.Settings.FullNameOfTheUser'无法分配给它 - 它是只读的F:\ CS \ MyApplication \ MyApplication.BO \ MyApplicationInfo.cs 57 17 MyApplication.BO

我的做法出了什么问题?

有帮助吗?

解决方案

在“设置”设计器中,确保将FullNameOfTheUser的Scope属性设置为“User”。如果创建应用程序作用域设置,则会将其生成为只读属性。有关详细信息,请参阅这篇文章

其他提示

设置需要有用户,而不是应用范围。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top