Debug Legacy code in Ctrader 4.2.x

Created at 16 Aug 2022, 02:26
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
DE

deolaolalere

Joined 19.12.2021

Debug Legacy code in Ctrader 4.2.x
16 Aug 2022, 02:26


The instruction on the document page https://help.ctrader.com/ctrader-automate/debugging/#creating-your-first-ctrader-custom-indicator does not work if you are trying to debug net4.x code . The old approach of attaching debugger to the ctrader process doesnt work either , how do you debug old code targeting net4.x using visual studio ?


@deolaolalere
Replies

PanagiotisCharalampous
16 Aug 2022, 15:19

Hi deolaolalere,

Please make sure that AccessRights are set to FullAccess.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

deolaolalere
16 Aug 2022, 21:18 ( Updated at: 16 Aug 2022, 22:33 )

RE:

PanagiotisCharalampous said:

Hi deolaolalere,

Please make sure that AccessRights are set to FullAccess.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

The bot code is on FullAccess

 

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class bkT_exp_2_cBot : Robot

}

 

And the line is placed in the OnStart

 

  protected override void OnStart()
        {
            var result = System.Diagnostics.Debugger.Launch();

            if (result is false)
            {
                Print("Debugger launch failed");
            }

}


@deolaolalere

PanagiotisCharalampous
17 Aug 2022, 08:06

Hi deolaolalere,

It works fine for me. Could you record a video with the exact steps you are following?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

deolaolalere
17 Aug 2022, 19:54

RE:

PanagiotisCharalampous said:

Hi deolaolalere,

It works fine for me. Could you record a video with the exact steps you are following?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Thanks PanagiotisCharalampous

I have approached it from first principles confirm the instruction works on other bots . The issue I raised still remained on the in question bot . The process is terminating unexpectedly (process was unexpectedly terminated.) The platform is unable to load an assembly in a third party library I am using , the failure is silent and doesn't even get to the loading of the diagnostic, which led me to believe perhaps the instruction doesn't work for legacy code

Another variant of the error is 

Crashed in OnStart with InvalidOperationException: Cannot load assembly Microsoft.Data.SqlClient

I have not resolved the issue above as to why it cannot load the assembly , when I remove that dependnecy everything works OK.  with library it builds in Visual studio but ctrader cannot load it.

I will have to find alternative approach . The library in question is linqtodb

 

 


@deolaolalere