应用程序设置保存

发布于 2024-08-12 06:18:17 字数 828 浏览 3 评论 0原文

我的应用程序中有两个程序集。 MyApplication.BOMyApplication.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

我的有什么问题方法?

I have two assemblies in my application. MyApplication.BO and MyApplication.GUI.

I have configured property-settings for my BO assembly.

Now when I am trying to compile the following code:

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 is giving me the following compilation error:

Error 1 Property or indexer 'MyApplication.BO.Properties.Settings.FullNameOfTheUser' cannot be assigned to -- it is read only F:\CS\MyApplication\MyApplication.BO\MyApplicationInfo.cs 57 17 MyApplication.BO

What is wrong with my approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牵你手 2024-08-19 06:18:17

在设置设计器中,确保 FullNameOfTheUser 的 Scope 属性设置为“User”。如果您创建应用程序范围的设置,它将生成为只读属性。有关详细信息,请参阅本文

In the Settings designer, make sure that the Scope property for FullNameOfTheUser is set to "User". If you create an Application-scoped setting, it is generated as a read-only property. Take a look at this article for more information.

层林尽染 2024-08-19 06:18:17

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

The setting needs to have user, not application scope.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文