SQLite C# WPF reading error -


i new c# , tring read .db file, have added ado.net 2.0 provider sqlite project link: http://sourceforge.net/projects/sqlite-dotnet2/. getting error when running , can not understand problem.

using system; using system.collections.generic; using system.linq; using system.text; using system.windows; using system.windows.controls; using system.windows.data; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.imaging; using system.windows.navigation; using system.windows.shapes; using system.data; using system.diagnostics; using system.data.sqlite;   namespace wpfapplication1.screens {     /// <summary>     /// interaction logic firstscreen.xaml     /// </summary>     public partial class firstscreen : usercontrol, iswitchable     {          public firstscreen()         {             initializecomponent();              debug.writeline("send debug output.");                           string connstring = "data source=c:\\projects.db";             using (sqliteconnection conn = new sqliteconnection(connstring))             {                 stringbuilder query = new stringbuilder();                 query.append("select app ");                 query.append("from alqueva ");                  using (sqlitecommand cmd = new sqlitecommand(query.tostring(), conn))                 {                     conn.open();                     using (sqlitedatareader dr = cmd.executereader())                     {                         while (dr.read())                         {                            debug.writeline(dr.getvalue(0) + " " + dr.getvalue(1) + " " + dr.getvalue(2));                         }                     }                 }             }             //console.readline();          }      } } 

error:

system.windows.markup.xamlparseexception unhandled   message='the invocation of constructor on type 'wpfapplication1.mainwindow' matches specified binding constraints threw exception.' line number '3' , line position '9'.   source=presentationframework   linenumber=3   lineposition=9   stacktrace:        @ system.windows.markup.xamlreader.rewrapexception(exception e, ixamllineinfo lineinfo, uri baseuri)        @ system.windows.markup.wpfxamlloader.load(xamlreader xamlreader, ixamlobjectwriterfactory writerfactory, boolean skipjournaledproperties, object rootobject, xamlobjectwritersettings settings, uri baseuri)        @ system.windows.markup.wpfxamlloader.loadbaml(xamlreader xamlreader, boolean skipjournaledproperties, object rootobject, xamlaccesslevel accesslevel, uri baseuri)        @ system.windows.markup.xamlreader.loadbaml(stream stream, parsercontext parsercontext, object parent, boolean closestream)        @ system.windows.application.loadbamlstreamwithsyncinfo(stream stream, parsercontext pc)        @ system.windows.application.loadcomponent(uri resourcelocator, boolean bskipjournaledproperties)        @ system.windows.application.dostartup()        @ system.windows.application.<.ctor>b__1(object unused)        @ system.windows.threading.exceptionwrapper.internalrealcall(delegate callback, object args, int32 numargs)        @ ms.internal.threading.exceptionfilterhelper.trycatchwhen(object source, delegate method, object args, int32 numargs, delegate catchhandler)        @ system.windows.threading.dispatcheroperation.invokeimpl()        @ system.windows.threading.dispatcheroperation.invokeinsecuritycontext(object state)        @ system.threading.executioncontext.runtrycode(object userdata)        @ system.runtime.compilerservices.runtimehelpers.executecodewithguaranteedcleanup(trycode code, cleanupcode backoutcode, object userdata)        @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state)        @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean ignoresyncctx)        @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state)        @ system.windows.threading.dispatcheroperation.invoke()        @ system.windows.threading.dispatcher.processqueue()        @ system.windows.threading.dispatcher.wndprochook(intptr hwnd, int32 msg, intptr wparam, intptr lparam, boolean& handled)        @ ms.win32.hwndwrapper.wndproc(intptr hwnd, int32 msg, intptr wparam, intptr lparam, boolean& handled)        @ ms.win32.hwndsubclass.dispatchercallbackoperation(object o)        @ system.windows.threading.exceptionwrapper.internalrealcall(delegate callback, object args, int32 numargs)        @ ms.internal.threading.exceptionfilterhelper.trycatchwhen(object source, delegate method, object args, int32 numargs, delegate catchhandler)        @ system.windows.threading.dispatcher.invokeimpl(dispatcherpriority priority, timespan timeout, delegate method, object args, int32 numargs)        @ ms.win32.hwndsubclass.subclasswndproc(intptr hwnd, int32 msg, intptr wparam, intptr lparam)        @ ms.win32.unsafenativemethods.dispatchmessage(msg& msg)        @ system.windows.threading.dispatcher.pushframeimpl(dispatcherframe frame)        @ system.windows.threading.dispatcher.pushframe(dispatcherframe frame)        @ system.windows.application.rundispatcher(object ignore)        @ system.windows.application.runinternal(window window)        @ system.windows.application.run(window window)        @ system.windows.application.run()        @ wpfapplication1.app.main() in c:\users\user\documents\visual studio 2010\projects\wpfapplication1\wpfapplication1\obj\x86\debug\app.g.cs:line 0        @ system.appdomain._nexecuteassembly(runtimeassembly assembly, string[] args)        @ system.appdomain.executeassembly(string assemblyfile, evidence assemblysecurity, string[] args)        @ microsoft.visualstudio.hostingprocess.hostproc.runusersassembly()        @ system.threading.threadhelper.threadstart_context(object state)        @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean ignoresyncctx)        @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state)        @ system.threading.threadhelper.threadstart()   innerexception: system.io.fileloadexception        message=mixed mode assembly built against version 'v2.0.50727' of runtime , cannot loaded in 4.0 runtime without additional configuration information.        source=wpfapplication1        stacktrace:             @ wpfapplication1.screens.firstscreen..ctor()             @ wpfapplication1.mainwindow..ctor() in c:\users\user\documents\visual studio 2010\projects\wpfapplication1\wpfapplication1\mainwindow.xaml.cs:line 17        innerexception:  

your sqlite connection must like:

data source=name.db;version=3; 

connection strings sqlite

in app.config add

<startup uselegacyv2runtimeactivationpolicy="true">   <supportedruntime version="v4.0"/> </startup> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -