This question is locked. New answers and comments are not allowed.
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:
I added the reference of
By the way i tried to load the assembly dynamically from the
So, the problem is how to add reference or assembly to the scope.
Thanks in advance.
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.