2009-11-27 91 views
7

我的应用程序中有两个程序集。 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是给我下面的编译错误:

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

什么是错我的做法?

回答

18

在设置设计器中,确保FullNameOfTheUser的Scope属性设置为“User”。如果您创建应用程序作用域设置,它将生成为只读属性。看看this article了解更多信息。

1

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

相关问题