【问题标题】:Problem with SQLiteConnection in C# WPFC# WPF 中的 SQLiteConnection 问题
【发布时间】:2011-08-05 17:19:58
【问题描述】:

我正在开发一个带有嵌入式 SQLite 数据库的 C# WPF 项目。我之前使用过 SQLite 没有问题,但是当我打电话时出于某种原因:

SQLiteConnection conn = new SqliteConnection("my connection string");

但是,当这段代码执行时,它会显示错误

XamlParserException 未处理 无法创建在程序集“MyProject”中定义的 MainWindow.xaml 的实例,版本 = 1.0.0.0... 调用的目标已引发异常。标记文件“MainWindow.xaml”第 1 行位置 9 中的错误。

此位置是XAML文件中的以下代码

<Window xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"  x:Class="MySQLBackup.MainWindow"

我已将项目设置为 .Net Framework 3.5,所以我不明白为什么我会收到此错误以及为什么它在调用类文件中的 SQLiteConnection 时说它是 XAML 中的错误。

感谢您提供的任何帮助。

更新 如下要求的是堆栈跟踪和内部异常

内部异常

System.Configuration.ConfigurationErrorsException:无法识别 配置部分 userSettings/Gui.Properties.Settings。 (C:\Users\Chris\AppData\Local\Microsoft\MySQLBackup.vshost.exe_Url_5ar2cuyxbdeg3v0bx5aak4mgjx2jmsbn\1.0.0.0\user.config 第 17 行)在 System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(布尔值 忽略本地)在 System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors 架构错误)在 System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors() 在 System.Configuration.ClientConfigurationSystem.OnConfigRemoved(对象 发件人,InternalConfigEventArgs e)

堆栈跟踪

在 System.Configuration.ClientConfigurationSystem.OnConfigRemoved(对象 发件人,InternalConfigEventArgs e) 在 System.Configuration.Internal.InternalConfigRoot.OnConfigRemoved(InternalConfigEventArgs 吃 System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(字符串 configPath, BaseConfigurationRecord configRecord) 在 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串 configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject、布尔型 requestIsHere、Object& 结果、Object& 结果运行时间对象)在 System.Configuration.BaseConfigurationRecord.GetSection(字符串 configKey, Boolean getLkg, Boolean checkPermission) 在 System.Configuration.BaseConfigurationRecord.GetSection(字符串 配置密钥)在 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(字符串 节名)在 System.Configuration.ConfigurationManager.GetSection(字符串 节名)在 System.Configuration.ClientSettingsStore.ReadSettings(字符串 sectionName, Boolean isUserScoped) 在 System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext 上下文,SettingsPropertyCollection 属性)在 System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider 提供者)在 System.Configuration.SettingsBase.GetPropertyValueByName(字符串 propertyName) 在 System.Configuration.SettingsBase.get_Item(String 属性名称)在 System.Configuration.ApplicationSettingsBase.GetPropertyValue(字符串 属性名称)在 System.Configuration.ApplicationSettingsBase.get_Item(字符串 属性名称)在 MySQLBackup.Properties.Settings.get_app_dbPassword() 在 c:\用户\克里斯\文档\视觉工作室 2010\Projects\MySQLBackup\MySQLBackup\Properties\Settings.Designer.cs:line 43 在 MySQLBackup.SqlDatabaseWork..ctor() 中 c:\users\chris\documents\visual studio

2010\Projects\MySQLBackup\MySQLBackup\Logic\SqlDatabaseWork.cs:25 行

【问题讨论】:

  • 你能显示异常的堆栈跟踪吗?
  • 这个错误与SQLite无关... XamlParseException的InnerException是什么?
  • 我已将异常和堆栈跟踪作为问题更新

标签: c# wpf sqlite .net-3.5 system.data.sqlite


【解决方案1】:

我已经设法解决了。我认为这与应用程序创建的 user.config 文件有关。我删除了 user.config,然后告诉 Visual Studio 重建,然后它似乎工作了。

感谢您的帮助

【讨论】:

    猜你喜欢
    • 2020-07-17
    • 2011-03-01
    • 1970-01-01
    • 2016-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多