2011-08-05 38 views
1

我正在開發一個嵌入式SQLite數據庫的C#WPF項目。我以前使用的SQLite沒有問題,但由於某種原因,當我打電話:C#中的SQLiteConnection問題WPF

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

然而,當這個代碼執行它顯示錯誤

XamlParserException了未處理 無法創建MainWindow.xaml的實例定義在彙編'MyProject'中,版本= 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,從而我不明白爲什麼我得到這個錯誤,以及爲什麼它在XAML中調用類文件中的SQLiteConnection時發生錯誤。

感謝您提供的任何幫助。

UPDATE 如以下請求是棧跟蹤和內部異常

內部異常

System.Configuration.ConfigurationErrorsException:無法識別 配置部分userSettings/Gui.Properties.Settings。 (C:\用戶\克里斯\應用程序數據\本地\微軟\ MySQLBackup.vshost.exe_Url_5ar2cuyxbdeg3v0bx5aak4mgjx2jmsbn \ 1.0.0.0 \ user.config 線17)維持在 系統 System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(布爾 ignoreLocal)。 Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)在 System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()在 System.Configuration.ClientConfigurationSystem.OnConfigRemoved(對象 發件人,InternalConfigEventArgs E)

堆棧跟蹤

在 System.Configuration.ClientConfigurationSystem.OnConfigRemoved(對象 發件人,InternalConfigEventArgs e)上 System.Configuration.Internal.InternalConfigRoot.OnConfigRemoved(InternalConfigEventArgs e)上 System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl (字符串 用configPath,BaseConfigurationRecord configRecord)在 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串 configKey,布爾getLkg,布爾的checkPermission,布爾 getRuntimeObject,布爾requestIsHere,對象&結果,OB系統配置.BaseConfigurationRecord.GetSection(字符串 configKey,布爾getLkg,布爾checkPermission) System.Configuration.BaseConfigurationRecord。GetSection(字符串 configKey)在 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(字符串 sectionName)在 System.Configuration.ConfigurationManager.GetSection(字符串 sectionName)在 System.Configuration.ClientSettingsStore。 ReadSettings(字符串 sectionName,布爾isUserScoped)在 System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext 上下文,SettingsPropertyCollection屬性)在 System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider 提供商)在 System.Configuration.SettingsBase.GetPropertyValueByNa我(字符串 propertyName的)在System.Configuration.SettingsBase.get_Item(字符串 propertyName的)在 System.Configuration.ApplicationSettingsBase.GetPropertyValue在 System.Configuration.ApplicationSettingsBase.get_Item(字符串 propertyName的)(字符串 propertyName的)在 MySQLBackup ()中的 c:\ users \ chris \ documents \ visual studio 2010 \ Projects \ MySQLBackup \ MySQLBackup \ Properties \ Settings.Designer.cs:行 43 MySQLBackup.SqlDatabaseWork.ctor()中的.Properties.Settings.get_app_dbPassword在 c:\ users \ chris \ documents \ visual studio

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

+0

可以顯示異常的堆棧跟蹤? –

+1

這個錯誤與SQLite無關......什麼是XamlParseException的InnerException? –

+0

我把異常和堆棧跟蹤作爲問題中的更新 – Boardy

回答

0

我已經設法解決它。我認爲這與應用程序創建的user.config文件有關。我刪除了user.config,然後告訴visual studio重建,然後它似乎工作。

感謝您的幫助