Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

My Revit app can't find SQLite. dll

18 REPLIES 18
Reply
Message 1 of 19
Anonymous
1246 Views, 18 Replies

My Revit app can't find SQLite. dll

I am trying to use SQLite in my c# app to store data but I got file not find althought I refenced in the app, put it in all possible folders.

What to do? See the image.

0000.jpg

Tags (3)
18 REPLIES 18
Message 2 of 19
MarryTookMyCoffe
in reply to: Anonymous

look at this https://forums.autodesk.com/t5/revit-api-forum/3rd-party-dll-in-revit-addin/m-p/7746443#M28372 and if you start from RevitManager it can not load it with referenced dll
-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 3 of 19
JimJia
in reply to: Anonymous

Hi usama, Please put SQLite.dll to the same folder with your external applicaiton "Licenses" dll. After that, your app will find the SQLite.dll when it runs.

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 4 of 19
oakam
in reply to: JimJia

Thank you for the answer. Actually it is there. When I add a refrence to the sqlite.dll in the Revit.exe directory it works.
Message 5 of 19
jeremytammik
in reply to: oakam

Revit.exe directory is the key. Alternatively, use a .NET assembly resolver:

 

http://thebuildingcoder.typepad.com/blog/2014/05/rvtva3c-assembly-resolver.html

 

Cheers,

 

Jeremy

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 19
Tripler123
in reply to: jeremytammik

Hi Jeremy,

 

i have the same problem. I try use Assembly.LoadFrom(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "System.Data.SQLite.dll")); but don't working.

Message 7 of 19
Anonymous
in reply to: jeremytammik

I have the same problem. My plugin program run on Revit 2021. I make sure that Revit 2021 have not 'System.Data.SQLite.dll'. I don't know why tell me 'cannot load the dll'.

I haved try using 'Linq2Db' and 'EntityFramework' for sqlite to do, but I failed. If you have solution, please tell me. 

Thinks!

Message 8 of 19
MarryTookMyCoffe
in reply to: Anonymous

try read what path it give you back before calling dll.

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 9 of 19
Anonymous
in reply to: MarryTookMyCoffe

The dll path is valid. I guess that revit maybe not work well. My solution: Dapper+System.Data.SQLite.Core+DapperExtensions. You will can write lambda expression to do anything.

Demo: https://github.com/kelicto/HelloDapper. EntityFramework and Linq2Db cannot do that and throw exception.

Message 10 of 19
Sean_Page
in reply to: Anonymous

I ran into issues recently in 2022 related to references that previously worked and turning on and using the Fusion Assembly Binding log viewer was a substantial help.

"Fuslogvw.exe (Assembly Binding Log Viewer) | Microsoft Docs" https://docs.microsoft.com/en-us/dotnet/framework/tools/fuslogvw-exe-assembly-binding-log-viewer

Message 11 of 19
joshua.lumley
in reply to: Anonymous

SQlite is dependent on these two .net binaries that Revit does not load, therefore they also need to be loaded along with it:
Microsoft.WindowsAPICodePack.dll
Microsoft.WindowsAPICodePack.Shell.dll

Message 12 of 19
Anonymous
in reply to: joshua.lumley

Maybe you are right. But why don't auto load them? 'Assembly.LoadFrom' method can auto load all required dlls. And the sqlite should give us all dlls.

Message 13 of 19
Anonymous
in reply to: Anonymous

Please see my demo, it's very nice to assess sqlite db by lambda.

Message 14 of 19
joshua.lumley
in reply to: Anonymous

What we're doing is API programming, unlike creating a standlone program there is no auto Loading and Revit is not going to load a single assembly unless explicitly told to do so.  When loading assemblies I'm careful to examine what has already been loaded in order to avoid double loading and creating a memory leak.

 

See if you can make sense of the below code, to get my meaning.. 

And do you have a link to the demo.

 

 

 

            if (AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName == stringWindowsAPICodePack).Count() == 0)
            {
                Assembly.Load(File.ReadAllBytes(path + "\\Microsoft.WindowsAPICodePack.dll"));
            }
            if (AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName == stringWindowsAPICodePackShell).Count() == 0)
            {
                Assembly.Load(File.ReadAllBytes(path + "\\Microsoft.WindowsAPICodePack.Shell.dll"));
            }
            //2 August 2019: End.

            Properties.Settings.Default.AssemblyNeedLoading = false;
            Properties.Settings.Default.Save();

 

 

 

Message 15 of 19
Anonymous
in reply to: joshua.lumley

To access Sqlite db, I use System.Data.SQLite.dll.

I don't understand why should this. 

kelicto9SEKZ_0-1621935578461.png

 

Tags (1)
Message 16 of 19
Anonymous
in reply to: Anonymous

Sorry, it's invalid message. I don't know how to close it.

Message 17 of 19
joshua.lumley
in reply to: Anonymous

Keep trying, your close to finding the solution. 

Message 18 of 19
f.robberts
in reply to: joshua.lumley

Hello @joshua.lumley ,

Thanks for your great answer it helped me a lot.
Could you tell me which using you need for the following snippet, and why it is needed? It seem to be working without.

     Properties.Settings.Default.AssemblyNeedLoading = false;
     Properties.Settings.Default.Save();

 Best regards,

 

François R

Message 19 of 19
joshua.lumley
in reply to: f.robberts

This code is in the IExternalCommand interface (when the user clicks a button) and only needs to be run once per session. The AssemblyNeedLoading variable is set to true on launch. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community