My Revit app can't find SQLite. dll

My Revit app can't find SQLite. dll

Anonymous
Not applicable
2,464 Views
18 Replies
Message 1 of 19

My Revit app can't find SQLite. dll

Anonymous
Not applicable

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

0 Likes
2,465 Views
18 Replies
Replies (18)
Message 2 of 19

MarryTookMyCoffe
Collaborator
Collaborator
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
0 Likes
Message 3 of 19

JimJia
Alumni
Alumni
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
0 Likes
Message 4 of 19

Anonymous
Not applicable
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.
0 Likes
Message 5 of 19

jeremytammik
Autodesk
Autodesk

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
Advocate
Advocate

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.

0 Likes
Message 7 of 19

Anonymous
Not applicable

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!

0 Likes
Message 8 of 19

MarryTookMyCoffe
Collaborator
Collaborator

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

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 9 of 19

Anonymous
Not applicable

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.

0 Likes
Message 10 of 19

Sean_Page
Collaborator
Collaborator

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

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 11 of 19

joshua.lumley
Advocate
Advocate

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

0 Likes
Message 12 of 19

Anonymous
Not applicable

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.

0 Likes
Message 13 of 19

Anonymous
Not applicable

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

0 Likes
Message 14 of 19

joshua.lumley
Advocate
Advocate

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
Not applicable

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

I don't understand why should this. 

kelicto9SEKZ_0-1621935578461.png

 

0 Likes
Message 16 of 19

Anonymous
Not applicable

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

0 Likes
Message 17 of 19

joshua.lumley
Advocate
Advocate

Keep trying, your close to finding the solution. 

0 Likes
Message 18 of 19

Anonymous
Not applicable

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

0 Likes
Message 19 of 19

joshua.lumley
Advocate
Advocate

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. 

0 Likes