A bot which includes a nuget package (SQLite)
A bot which includes a nuget package (SQLite)
15 Dec 2022, 12:26
Hi,
I've been a developer for years but I'm a complete novice when it comes to .net, c# and visual studio so it's possible what I'm about to ask is incredibly basic but I'm stuck so I hope you can help!
I've got a SQLite database which is being populated by another application, and I need my cBot to read some data from it. I've found a package which I think will allow me to do that: System.Data.SQLite. I installed this using nuget via the dotnet command line interface: dotnet add package System.Data.SQLite --version 1.0.117 which seems to work. I've included it via a line in Visual Studio like "using System.Data.SQLite" and I'm able to Build the project without errors.
The problem is that when I am unable to build the bot via the cTrader application. If I try it fails with "System.Data.SQLite is not supported". If I add lines of code to try and interact with my SQLite database like:
protected override void OnStart()
{
// To learn more about cTrader Automate visit our Help Center:
// https://help.ctrader.com/ctrader-automate
SQLiteConnection sqlite_conn = new SQLiteConnection("Data Source=database.sqlite;Version=3;");Print(Message);
}
Then it fails with an error like "Crashed in OnStart with DLLNotFoundException: Unable to load DLL.
I think what I need to do is the include a reference to the DLL via the "Manage References" option in cTrader and then find the correct DLL. Problem is it's not a DLL it's a .nupkg and a number of other files.
So, assuming I'm on the right path, my question is how can I use a nuget package from my cBot?
Many thanks
mshaw1989
15 Dec 2022, 23:00
I've worked this out, and I was way off.
It was because I never changed the access rights of the Robot from [Robot(AccessRights = AccessRights.None)] to [Robot(AccessRights = AccessRights.FullAccess)]. I'm guessing what was happening was it was trying to load the DLL file but failing because it didn't have permission.
@mshaw1989