Topics
Replies
noeyamn
09 Mar 2020, 21:56
Thansk Panagiotis for telling me about AccessRights.
After giving AccessRights.FullAccess to the bot, the exception is back again when starting bot:
Compilation is Ok
Crashed in OnStart with DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I have the minimum code :
using System;
using System.Data.SQLite;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
private SQLiteConnection _SqliteConnection;
protected override void OnStart()
{
String dataBasePath = "D:\\DBTest.sqlite";
_SqliteConnection = new SQLiteConnection("Data Source=" + dataBasePath + "; Version=3; FailIfMissing=True;");
_SqliteConnection.Open();
}
protected override void OnTick()
{
}
protected override void OnStop()
{
}
}
}
with net40 System.data.sqlite.dll referenced in ctrader and package installed in VS
@noeyamn
noeyamn
09 Mar 2020, 16:03
( Updated at: 21 Dec 2023, 09:21 )
RE:
PanagiotisCharalampous said:
Hi noeyamn,
You did not answer my question. Why do you add references manually? I installed SQLite using Package Manager and I have no problems. See below
Everything seems fine and the cBot builds without a problem.
Best Regards,Panagiotis
Hi Panagiotis,
I manually load the assembly to avoid the exception "Unable to load DLL 'SQLite.Interop.dll'" when running the bot only (compilation was succesful)
The exception happens to me when starting the bot.
Did you try running the bot you showed on the screenshot ?
___________________________
I have just restarted from scratch with a brand new bot and the error is different now :
=> Crashed in OnStart with TypeInitializationException: The type initializer for 'System.Data.SQLite.UnsafeNativeMethods' threw an exception.
The error happens when starting bot. Compilation is succesful
When placing a breakpoint, the error happens on
_SqliteConnection = new SQLiteConnection("Data Source=" + dataBasePath + "; Version=3; New=True;");
It is a security exception
@noeyamn
noeyamn
06 Mar 2020, 21:31
RE:
PanagiotisCharalampous said:
Hi noeyamn,
I cannot reproduce any errors when installing from NuGet. Why do you add references manually? The Package Manager should take care of this automatically.
Best Regards,
Panagiotis
Here is how I get the error :
- (VS 2019 ) : nuget : install System.Data.SQLite package
- (ctrader / manage bot reference) : add reference to C:\Users\Me\Documents\cAlgo\Sources\Robots\MyBot\packages\System.Data.SQLite.Core.1.0.112.0\lib\net40\System.Data.SQLite.dll
Then write some code to open a connection to db (the following is what I have tried)
String dataBasePath = @"D:\DB.sqlite";
SQLiteConnection _SqliteConnection = new SQLiteConnection("Data Source=" + dataBasePath + "; Version=3; FailIfMissing=True;");
SQLiteConnection _SqliteConnection.Open();
Then lunch bot
@noeyamn
noeyamn
05 Mar 2020, 12:55
Hi everyone
I am taking back my previous message saying that it I succeeded to make it work:
I have the same issue.
This is what I tried :
- (VS 2019 ) : nuget : install System.Data.SQLite package
- (ctrader / manage bot reference) : add reference to C:\Users\Me\Documents\cAlgo\Sources\Robots\MyBot\packages\System.Data.SQLite.Core.1.0.112.0\lib\net40\System.Data.SQLite.dll
Here is a bypass : I am currently running it by loading dll from code :
Here is how I connect :
_SqliteAssembly = Assembly.LoadFrom(@"C:\Users\Me\Documents\cAlgo\Sources\Robots\MyBot\packages\System.Data.SQLite.Core.1.0.112.0\lib\net40\System.Data.SQLite.dll");
Type sqliteConnectionType = _SqliteAssembly.GetType("System.Data.SQLite.SQLiteConnection");
_SqliteConnection = Activator.CreateInstance(sqliteConnectionType, new object[] { "Data Source=" + dataBasePath + "; Version=3; FailIfMissing=True;" });
sqliteConnectionType.GetMethod("Open").Invoke(_SqliteConnection, null);
I do the rest by using reflection to invoke methods, this is quit tidious but it works
Cheers
@noeyamn
noeyamn
11 Dec 2019, 10:49
RE:
PanagiotisCharalampous said:
Hi noeyamn,
Shall I assume you are using visual backtesting? If yes, for performance reasons some ticks are skipped by the chart so the indicator displayed on the chart might have these deviations. The correct values are the ones recorded by your cBot.
Best Regards,
Panagiotis
First of all, thank you very much for your attention and your answer.
Yes, I am using visual backtesting.
I understand the performance reason, however I have to say that this is really annoying because the analyze produced form an indicator is sometimes diverging from what is visible on the chart.
I generally put the chart on one screen and the bot analyze on an other (I run the interface in a distinct application), and having contradictions between the chart and the bot makes testing dodgy as I can not be sure if the error is from the code or be cause the chart is diverging.
Is there any plan to change that in future versions ?
Any suggestion to manage this ?
Thanks :-)
@noeyamn
noeyamn
11 Mar 2020, 22:27
Thank you very much Panagiotis and the ctrader team for the workaround that you proposed.
Is it going to be a fix in a future release ?
@noeyamn