Let us assume that a Revit add-in references a SQLite Database (version 1.0.80.0) and the SQLite library files are deployed within the Revit add-in application. Since Revit uses SQLite (version 1.0.60.0) itself and invokes the add-in, it will generate a version conflict during runtime.
InvalidCastException: System.Data.SQLite.SQLiteConnection cannot be cast to [B]System.Data.SQLite.SQLiteConnection. Type A originates from ‘System.Data.SQLite, Version=1.0.60.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139’ in the context ‘Default’ at location ‘C:\Windows\assembly\GAC_64\System.Data.SQLite\1.0.60.0__db937bc2d44ff139\System.Data.SQLite.dll’. Type B originates from ‘System.Data.SQLite, Version=1.0.80.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139’ in the context ‘Default’ at location ‘C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data.SQLite\v4.0_1.0.80.0__db937bc2d44ff139\System.Data.SQLite.dll’.
How can we resolve this exception?
Here are the two approaches that came up during the internal discussions:
- Change the add-in to use 1.0.60 for Revit 2013
- Or use a different AppDomain for the code that accesses the SQLite database. Since the Revit API communication must be in the standard domain, there will need to be a way to get the needed data across the boundary.

Leave a Reply to SaikatCancel reply