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

SQLite With Open Access Problem

1 Answer 91 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
zenus
Top achievements
Rank 1
zenus asked on 09 Aug 2011, 08:56 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 the 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 convert the project from class library to Console application and invoke 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.

1 Answer, 1 is accepted

Sort by
0
zenus
Top achievements
Rank 1
answered on 09 Aug 2011, 09:07 AM
Sorry I posted in wrong forum, i moved it to: ORM > General  Discussion / Developer Productivity Tools Forums / OpenAccess ORM > General Discussions >
Tags
General Discussions
Asked by
zenus
Top achievements
Rank 1
Answers by
zenus
Top achievements
Rank 1
Share this question
or