in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

System.Data.SQLite.SQLiteConnection InvalidCastException Error

Last post 07-14-2010 11:45 AM by Vincent_Ugenti. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 10-20-2009 7:56 AM

    System.Data.SQLite.SQLiteConnection InvalidCastException Error

    Hello,

    I'm getting an error when my app starts up now. 

    The error reads:  Unable to cast object of type 'System.Data.SQLite.SQLiteConnection' to type 'System.Data.SQLite.SQLiteConnection'.

    Stack Trace:

       at System.Data.SQLite.SQLiteCommand.set_DbConnection(DbConnection value)
       at System.Data.Common.DbCommand.set_Connection(DbConnection value)
       at System.Data.Common.Utils.CommandHelper.SetStoreProviderCommandState(EntityCommand entityCommand, EntityTransaction entityTransaction, DbCommand storeProviderCommand)
       at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
       at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
       at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
       at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
       at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()

     

    Seems like a rather strange error...has anyone else seen this?

    I'm using 0.65 release.

  • 10-20-2009 8:06 AM In reply to

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    Are you sure all your code is compiled against the same version?  I usually set "specific version" to "false" in my project references to make sure.

  • 10-20-2009 11:55 AM In reply to

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    I set the System.Data.SQLite reference's value of Specific Version to false as well as the System.Data.SQLite.Linq reference as well.


    I'm still receiving the error however.

  • 10-20-2009 12:35 PM In reply to

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    Hi, I've figured it out.  Thank you so much for your help.  There was the old 0.60 dll file in my build directory that I forgot to replace with the new 0.65 dll.

    Thank you for your help.

  • 01-27-2010 1:33 PM In reply to

    • NGarg
    • Top 500 Contributor
    • Joined on 01-27-2010
    • Posts 6

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    Hi, I am getting the exact same error. I have uninstalled 0.60. What else can I do? You said that you had some old 0.60 dll files in your build directory. What files were those? Did you have to make any changes to App.config? NGarg
  • 01-27-2010 1:56 PM In reply to

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    System.Data.SQLite.DLL and System.Data.SQLite.Linq.dll.

    If your build directory is not the same place as /Debug (default option) then check your build directory that it has the updated DLL files.  Also, you will have to change your app.config...add this:

    <system.data>
          <DbProviderFactories>
            <remove invariant="System.Data.SQLite"/>
            <add name="SQLite Data Provider" invariant="System.Data.SQLite"
                 description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
          </DbProviderFactories>
      </system.data>
      <connectionStrings>
             <!-- This is just your connectionString that is generated for you -->
      </connectionStrings>
     

    Hope this helps!

  • 01-27-2010 6:11 PM In reply to

    • NGarg
    • Top 500 Contributor
    • Joined on 01-27-2010
    • Posts 6

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    I have the default build directories (/Debug and /Release). And I did a full clean followed by a rebuild. Also, I have these lines in the app.config, but that does not help as well. The weird part is that the solution is working fine on the development machine. Its the client machine that is having a problem.
  • 01-28-2010 10:37 AM In reply to

    • NGarg
    • Top 500 Contributor
    • Joined on 01-27-2010
    • Posts 6

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    Also, the regular sql statements are working in the code. If I do direct "SQLiteConnection conn = new SQLiteConnection"... and then do a select/update command. Those are working. It is the entity framework commands that are not working The client has multiple software loaded on their computer... possibly with different version of sqlite libraries. Can that affect?
  • 01-28-2010 10:44 AM In reply to

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

     I think that could affect things.  Make sure they are using the latest version of the SQLite dll as well.

  • 01-28-2010 11:18 AM In reply to

    • NGarg
    • Top 500 Contributor
    • Joined on 01-27-2010
    • Posts 6

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    I have asked the client to uninstall every SQLite application. And I checked to make sure that my software was installing the correct version (1.0.65.0). But the problem is still there. The client still gets the same error message. Is there a way to check if the client has some sqlite version marked in the registry somewhere?
  • 07-08-2010 9:40 AM In reply to

    • TJG
    • Not Ranked
    • Joined on 07-07-2010
    • Posts 3

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    You can look in the GAC (C:\Windows\Assembly) to see if there are any older versions of SQLite listed there. If so, the problem may be related to  http://sqlite.phxsoftware.com/forums/p/2333/9302.aspx#930.

  • 07-14-2010 11:45 AM In reply to

    Re: System.Data.SQLite.SQLiteConnection InvalidCastException Error

    I just posted a solution to this, see http://sqlite.phxsoftware.com/forums/p/2333/9615.aspx

    Hope you find this helpful.

    Sincerely,

    Vincent Ugenti

    Sr. Software Engineer

    MiMedia LLC

    www.mimedia.com

Page 1 of 1 (12 items)
Powered by Community Server (Commercial Edition), by Telligent Systems