当我尝试在后面的代码中使用最近添加的应用程序设置时,我编写的 WPF 应用程序将不再编译。我可以在设置设计器和应用程序配置中看到设置,如果我注释掉对设置的引用,将编译。
新设置旨在存储一个日期,通知它何时显示气球提示(如果最小化)。似乎任何新添加的设置都会破坏构建,无论它是什么类型。
是否有添加我不知道的新设置的步骤?
这是它的样子:
//designer, pretty much the same as all the other declarations:
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.DateTime BaloonLastSeen {
get {
return ((global::System.DateTime)(this["BaloonLastSeen"]));
}
set {
this["BaloonLastSeen"] = value;
}
}
<!-- app.config: -->
<userSettings>
<MyNS.MyApp>
<setting name="WindowState" serializeAs="String">
<value>-1</value>
</setting>
<setting name="BaloonLastSeen" serializeAs="String">
<value />
</setting>
</MyNS.MyApp>
</userSettings>
//and finally, my attempt to use it in code-behind:
System.DateTime baloon = Properties.Settings.Default.BaloonLastSeen;
通过工作调用其他属性Properties.Settings.Default
就好了,它只是最近添加的,它似乎被绊倒了。我试过清理和重建,甚至重新启动 Visual Studio,但似乎没有帮助。
另一条信息是尝试调用此属性会破坏智能感知。在尝试构建失败后,VS 将不再检测我输入的类型或成员名称,直到我重新启动。
以下是编译器所说的错误:
Error 31 'MyNS.MyApp.Properties.Settings' does not contain a definition for 'BaloonLastSeen' and no extension method 'BaloonLastSeen' accepting a first argument of type 'MyNS.MyApp.Properties.Settings' could be found (are you missing a using directive or an assembly reference?)
我做了什么!?