Using Sqlite dll from referenced project
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I've been scratching my head for days now around this issue. I have gone through the steps in this post already: https://forums.autodesk.com/t5/revit-api-forum/my-revit-app-can-t-find-sqlite-dll/m-p/10323105
However I keep running into the same error. Here is my situation:
I am workng on a project where someone else is doing the backend part and we are using Sqlite for storing a local database. The Sqlite dll files are referenced in this backend project and copied to the Revit project assembly path. All good there, however when the actual loading happens it will throw the usual error that it cannot load the assembly. I assume that this is because Revit is also making use of its own Sqlite dll and the wrong assemblies are referenced. So I tried subscribing to the AssemblyResolve event as mentioned in the previous forum post. Then when the event hits it will ge the correct dll file, but it still throws the same error. This time with an additional inner exception about assemblied being loaded in from outside sources:
I followed the link it mentions and I have tried adding this to the app.config file:
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
And I have also tried creating a separate domain to load the Sqlite assembly into, like this:
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string filename = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
filename = Path.Combine(filename, "System.Data.SQLite.dll");
PermissionSet trustedLoadFromRemoteSourceGrantSet = new PermissionSet(PermissionState.Unrestricted);
AppDomainSetup trustedLoadFromRemoteSourcesSetup = new AppDomainSetup();
trustedLoadFromRemoteSourcesSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
AppDomain trustedRemoteLoadDomain = AppDomain.CreateDomain("Trusted LoadFromRemoteSources Domain", null, trustedLoadFromRemoteSourcesSetup, trustedLoadFromRemoteSourceGrantSet);
Assembly assemblyRef;
if (File.Exists(filename))
{
assemblyRef = Assembly.LoadFile(filename);
trustedRemoteLoadDomain.Load(assemblyRef.FullName);
//AppDomain.CurrentDomain.Load(filename);
}
return null;
}
Neither of the above have gotten me any further and I keep getting the same exception.
Any help would be much appreciated.
Developer Advocacy and Support +