C# - 编译器错误:System.Configuration.ConfigurationErrorsException未处理 [英] C# - Compiler Error: System.Configuration.ConfigurationErrorsException was unhandled
问题描述
Hey Everyone,
如何在 return((string)(this [TargetDir])>; 上编译时解决编译器错误:
Hey Everyone, How do I fix the Compiler Error upon compiling on "return ((string)(this["TargetDir"]));":
System.Configuration.ConfigurationErrorsException was unhandled
Configuration system failed to initialize
{"Unrecognized configuration section userSettings/CCP.Settings1. (C:\\Users\\bmccarthy\\Documents\\Visual Studio 2008\\Projects\\CCP Utility\\CCP Utility\\bin\\Debug\\CCP_Utility.exe.config line 21)"}
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
这是我的Settings.Designer.cs文件中的Properties目录下的代码:
Here's the code in my Settings.Designer.cs file under the Properties directory:
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string TargetDir {
get {
return ((string)(this["TargetDir"]));
}
set {
this["TargetDir"] = value;
}
}
这里是CCP_Utility.exe.config的代码bin文件夹:
Here's the code for CCP_Utility.exe.config from the bin folder:
<CCP_Utility.Properties.Settings>
<setting name="SourceDir" serializeAs="String">
<value />
</setting>
<setting name="TargetDir" serializeAs="String">
<value />
</setting>
<setting name="CorpID" serializeAs="String">
<value />
</setting>
</CCP_Utility.Properties.Settings>
<CCP_Utility.Settings1>
<setting name="sourceDir" serializeAs="String">
<value />
</setting>
<setting name="targetDir" serializeAs="String">
<value />
</setting>
</CCP_Utility.Settings1>
CCP_Utility.Settings1>标签必须匹配?? App.config和什么?
What does the < CCP_Utility.Settings1 > tag have to match up to?? App.config and what else?
大写是否重要?我有变量声明为TargetDir Settings.Settings ....
Does capitalization matter? I have the variable declared as TargetDir Settings.Settings....
System.Configuration.dll文件位于哪里?
Where is the System.Configuration.dll file located?
推荐答案
验证UserScopedSettingAttribute与正确的设置部分匹配。
Verify UserScopedSettingAttribute matches up with the correct settings section.
如果我记得正确,是的,区分大小写。
If I remember correct, yes, case-sensitive.
通常,我将添加一个设置,save并关闭,然后再次打开设置设计器,并删除设置,保存并关闭。这将使设计器同步。我看到他们第一次在计算机上打开设计器时失去同步。 (例如,当您从源代码控制获得。)
Usually, I will add a setting, save and close, then open the settings designer again, and delete the setting, save and close. This will get the designer in-sync. I have seen them get out-of-sync the first time the designer is opened on a computer. (For example, when you get from source control.)
这篇关于C# - 编译器错误:System.Configuration.ConfigurationErrorsException未处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!