I am developing a C# WPF project with an embedded SQLite Database. I have used SQLite before without problems but for some reason when I call:
SQLiteConnection conn = new SqliteConnection("my connection string");
However, when this code executes it displays the error
XamlParserException was unhandled
Cannot create instance of MainWindow.xaml defined in assembly ‘MyProject’, Version=1.0.0.0…
Exception has been thrown by the target of an invocation. Error in markup file ‘MainWindow.xaml’ Line 1 position 9.
At this position is the following code in the XAML file
<Window xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" x:Class="MySQLBackup.MainWindow"
I have set the project to be .Net Framework 3.5 so I do not understandw why I am getting this error and why it is saying it is an error in the XAML when it calls the SQLiteConnection in the class file.
Thanks for any help you can provide.
UPDATE
As requested below is the stacktrace and inner exception
Inner Exception
System.Configuration.ConfigurationErrorsException: Unrecognized
configuration section userSettings/Gui.Properties.Settings.
(C:\Users\Chris\AppData\Local\Microsoft\MySQLBackup.vshost.exe_Url_5ar2cuyxbdeg3v0bx5aak4mgjx2jmsbn\1.0.0.0\user.config
line 17) at
System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean
ignoreLocal) at
System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors
schemaErrors) at
System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors() at
System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object
sender, InternalConfigEventArgs e)
Stacktrace
at
System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object
sender, InternalConfigEventArgs e) at
System.Configuration.Internal.InternalConfigRoot.OnConfigRemoved(InternalConfigEventArgs
e) at
System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(String
configPath, BaseConfigurationRecord configRecord) at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object& result, Object&
resultRuntimeObject) at
System.Configuration.BaseConfigurationRecord.GetSection(String
configKey, Boolean getLkg, Boolean checkPermission) at
System.Configuration.BaseConfigurationRecord.GetSection(String
configKey) at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
sectionName) at
System.Configuration.ConfigurationManager.GetSection(String
sectionName) at
System.Configuration.ClientSettingsStore.ReadSettings(String
sectionName, Boolean isUserScoped) at
System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext
context, SettingsPropertyCollection properties) at
System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider
provider) at
System.Configuration.SettingsBase.GetPropertyValueByName(String
propertyName) at System.Configuration.SettingsBase.get_Item(String
propertyName) at
System.Configuration.ApplicationSettingsBase.GetPropertyValue(String
propertyName) at
System.Configuration.ApplicationSettingsBase.get_Item(String
propertyName) at
MySQLBackup.Properties.Settings.get_app_dbPassword() in
c:\users\chris\documents\visual studio
2010\Projects\MySQLBackup\MySQLBackup\Properties\Settings.Designer.cs:line
43 at MySQLBackup.SqlDatabaseWork..ctor() in
c:\users\chris\documents\visual studio2010\Projects\MySQLBackup\MySQLBackup\Logic\SqlDatabaseWork.cs:line 25
I’ve managed to resolve it. I think it was something to do with the user.config file that is created by the application. I deleted the user.config and then told visual studio to rebuild and then it seemed to work.
Thanks for your help