vb.net - VS Community 中的 VB 项目中的 app.config 错误
问题描述
我试图让我的应用程序读取我在 app.config 文件中为我的 VB 项目创建的变量,并且遇到两个错误。在 VS 社区中进行开发(最新并使用最新的 .Net 框架)。
- 当我单击触发代码以从 app.config 文件中读取变量的表单按钮时。我收到此错误:
该按钮触发此代码: Dim strKey As String strKey = My.Settings.TestKey
- 当我打开/关闭 app.config 文件时,我看到错误“读取 app.config 文件时发生错误。文件可能已损坏或包含无效的 XML”。我已经通过在线检查器运行了 XML,它通过了。我将在底部粘贴 app.config XML。
app.config 文件是自动生成的,TestKey 变量是通过项目属性页面添加到其中的,所以我根本没有手动修改 app.config 文件。
任何建议都非常感激。
干杯,
周杰伦
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" >
<section name="Doghunter.My.MySettings" type="System.Configuration.ClientSettingsSection, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" requirePermission="false" />
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<applicationSettings>
<Doghunter.My.MySettings>
<setting name="TestKey" serializeAs="String">
<value>Zebedee</value>
</setting>
</Doghunter.My.MySettings>
</applicationSettings>
</configuration>
解决方案
推荐阅读
- javascript - Nodejs MongoDb query returns everything instead of matching document
- javascript - TLSSocket not reporting authorized and authorizationError correctly
- javascript - Why does typescript allow number entry in an enum if one value is set to a number?
- angular - Angular form always invalid
- kotlin - 内联扩展函数 (let/run/also/...) 生成未使用的局部变量
- javascript - props is not sending data to another component
- html - 为什么我的 CSS 按钮默认为在任何地方都没有提及的字体?
- import - importlib.h 如何从 Cpython 中的 importlib._bootstrap 生成?
- php - 激活插件后如何使用所选模板创建页面
- swift - 如何将 *Iproj 文件设置为不同的目标?