This is a migrated thread and some comments may be shown as answers.

SQLite reference in the data model.

3 Answers 116 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
zenus
Top achievements
Rank 1
zenus asked on 09 Aug 2011, 09:04 AM
Hello

I have tried to link my data model with SQLite database using configuration file and it works fine but i faced this problem.
When i tried an example of the data model (Classes) and data access layer in same project it works fine, but when i separated the data model in a class library it always gives this error when i tried to get the Scope:

theObjectScopeProvider1.myScope = GetNewObjectScope();
// The Error  : Could not load file or assembly 'System.Data.SQLite'

I added the reference of 'System.Data.SQLite' to class library as usual and it was working when i converted the project from class library to Console application and invoked the scope.
By the way i tried to load the assembly dynamically from the AdjustForDynamicLoad function but nothing changed:

static public void AdjustForDynamicLoad()
        {
            Assembly SQLiteAssembly = Assembly.LoadFile(@"C:\Lib\System.Data.SQLite.DLL");
            if( theObjectScopeProvider1 == null )
                theObjectScopeProvider1 = new ObjectScopeProvider1();
  
            if( theObjectScopeProvider1.myDatabase == null )
            {
                string assumedInitialConfiguration =
                           "<openaccess>" +
                               "<references>" +
                                   "<reference assemblyname='PLACEHOLDER' configrequired='True'/>" +
                                   "<reference assemblyname='PLACEHOLDEZ' configrequired='False'/>" +
                               "</references>" +
                           "</openaccess>";
                System.Reflection.Assembly dll = theObjectScopeProvider1.GetType().Assembly;
                assumedInitialConfiguration = assumedInitialConfiguration.Replace("PLACEHOLDER", dll.GetName().Name);
                //assumedInitialConfiguration = assumedInitialConfiguration.Replace("PLACEHOLDEZ", SQLiteAssembly.GetName().Name);
                System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
                xmlDoc.LoadXml(assumedInitialConfiguration);
                Database db = Telerik.OpenAccess.Database.Get("SQLiteDatabaseConnection",
                                            xmlDoc.DocumentElement,
                                            new System.Reflection.Assembly[] { dll, SQLiteAssembly. } );
  
                theObjectScopeProvider1.myDatabase = db;
            }
        }

So, the problem is how to add reference or assembly to the scope.

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Accepted
Nikola
Telerik team
answered on 11 Aug 2011, 03:42 PM
Hello Zenus,

I tried to reproduce the behavior you described, but to no avail. Following this topic out, I was able to successfully set up a sample solution for your convenience.

Please find attached file, it includes a VS2010 solution with two projects: one is a data access layer project, built on top of SQLite database, and the other is just a very basic WPF application that visualizes some data which is provided by the DAL.

Can you make sure that your executing project also has a reference to System.Data.SQLite. Also if the problem still persists it would be very useful if you could send us a sample project for debugging purposes.

Hope that helps and don't hesitate to contact us if you have any further troubles.

Greetings,
Nikola
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
zenus
Top achievements
Rank 1
answered on 12 Aug 2011, 10:37 PM
Thank you Mr.Nikola.
0
Nikola
Telerik team
answered on 16 Aug 2011, 07:03 AM
Hi Zenus,

I'm glad that I could help. Feel free to contact us for any OpenAccess problems.

Best wishes,
Nikola
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
General Discussions
Asked by
zenus
Top achievements
Rank 1
Answers by
Nikola
Telerik team
zenus
Top achievements
Rank 1
Share this question
or