gpt4 book ai didi

c# - System.Configuration.ConfigurationErrorsException异常

转载 作者:行者123 更新时间:2023-11-30 13:23:20 25 4
gpt4 key购买 nike

我有一个包含几个文本框的表单,您可以在文本框中输入一些值,然后当您按下提交时,它会将这些值保存到一个文件中。但是,当我按下提交时,出现以下异常。

System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section add. (C:\Program Files (x86)\Default Company Name\Setup\HomeInventory2.exe.Config line 3)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
--- End of inner exception stack trace ---
at HomeInventory2.Services.Factory.GetService(String servicename) in C:\Users\Protego\documents\visual studio 2010\Projects\HomeInventory2\HomeInventory2\Services\Factory.cs:line 37
at HomeInventory2.Business.Manager.GetService(String name) in C:\Users\Protego\documents\visual studio 2010\Projects\HomeInventory2\HomeInventory2\Business\Manager.cs:line 14
at HomeInventory2.Business.InventoryMngr.Create(CreateInventory inv) in C:\Users\Protego\documents\visual studio 2010\Projects\HomeInventory2\HomeInventory2\Business\InventoryMngr.cs:line 19
at HomeInventory2.Form1.submitButton_Click(Object sender, EventArgs e) in C:\Users\Protego\documents\visual studio 2010\Projects\HomeInventory2\HomeInventory2\Form1.cs:line 52
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

如果我没看错,问题出在我的 App.config 文件中。但我没有在该文件中看到任何问题 - 如下所示。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<add key="InventorySvc" value="HomeInventory2.Services.InventorySvc" />
</configuration>

最佳答案

<add key应该像<appSettings>一样在里面.没有配置 → 添加。它应该像配置 → appSettings → 添加

关于c# - System.Configuration.ConfigurationErrorsException异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12990706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com