BUG: crash when running .net6.0 target cBot
BUG: crash when running .net6.0 target cBot
13 Oct 2022, 20:08
cTraderVersion: 4.4.13
System: Windows 10 Pro
cBot: any sample cBot, tested on Sample cBot Reference SMA
Run instance of cBot compiled with target framework set to .NET6.0 and the cTrader crashes with exception:
System.InvalidOperationException: Output is empty
at cTrader.Automate.BrokerProcess.NetCoreBrokerProcess.OnInnerProcessOutputDataReceived(Object sender, DataReceivedEventArgs e)
at System.Diagnostics.Process.OutputReadNotifyUser(String data)
at System.Diagnostics.AsyncStreamReader.FlushMessageQueue(Boolean rethrowInNewThread)
--- End of stack trace from previous location ---
at System.Diagnostics.AsyncStreamReader.<>c.<FlushMessageQueue>b__18_0(Object edi)
at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
What is the reason of this?
Replies
eprofservices
14 Oct 2022, 11:57
( Updated at: 14 Oct 2022, 11:59 )
RE:
Spotware said:
Can you share some source code that will allow us to reproduce the problem?
Yes. The source code is standard "Sample cBot Reference SMA" as installed with cTrader:
// -------------------------------------------------------------------------------------------------
//
// This code is a cTrader Automate API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
//
// All changes to this file might be lost on the next application update.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// -------------------------------------------------------------------------------------------------
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SamplecBotReferenceSMA : Robot
{
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter("SMA Period", DefaultValue = 14)]
public int SmaPeriod { get; set; }
private SampleSMA sma;
protected override void OnStart()
{
sma = Indicators.GetIndicator<SampleSMA>(Source, SmaPeriod);
}
protected override void OnTick()
{
Print("{0}", sma.Result.LastValue);
}
}
}
But you probably won't be able to reproduce the error that easily. I tried to preproduce it myself on clean Win10 installation with only cTrader installed + dotnet 6.0 sdk (6.0.402) + some IDEs like Rider and Visual Studio Code and it works fine. There must be some conflict with other software I have on development machines - shared library update or something I don't know.
In any case, cTrader should not crash with exception.
Is the source code of cTrader available to debug?
@eprofservices
eprofservices
04 Dec 2022, 12:54
RE: RE:
eprofservices said:
Spotware said:
But you probably won't be able to reproduce the error that easily.Can you share some source code that will allow us to reproduce the problem?
I have found the way to reproduce the error and it looks that the cTrader (or Automate part) do not support creating symbolic link of source directory (...\Documents\cAlgo) to point into some other location (Windows link not Linux) especially the network drive location as I did. I don't know why because it should work on system level.
To reproduce the error please move the cAlgo from Documents into some network location (preferably on the separate machine - file server) and then create symbolic link:
mklink /D \\someserver\someshare\cAlgo cAlgo
Then my question is how to change the cAlgo location because after installation it is fixed to Documents directory and this is not (in general) good location for development sources.
@eprofservices
Spotware
14 Oct 2022, 07:46
Dear trader,
Can you share some source code that will allow us to reproduce the problem?
Best Regards,
cTrader Team
@Spotware