debugging with the new version

yuval.ein since: 08 May 2020;

  14 Sep 2022, 13:28
debugging with the new version

I've created a .Net 6 new cBot with it's default code and tried to debug it via VS2022 using the old way (Debug > attach to process > cTrader.exe) however the cBot did not stop on the breakpoint. Is there a new way of debugging with the new version?

Thanks

ctid3999979 since: 05 Jul 2021;

  17 Sep 2022, 12:39

The process appears to be completely different now.

  1. Near the beginning of your code change 
    [Robot(AccessRights = AccessRights.None)]

    to

    [Robot(AccessRights = AccessRights.FullAccess)]
  2. Add the following to the beginning of the OnStart() function 
    var result = System.Diagnostics.Debugger.Launch();
    
                if (result is false)
                {
                    Print("Debugger launch failed.");
                }
  3. Build you cBot
  4. You don't need to attach the process anymore. When you run the bot, or run a backtest in cTrader, you'll get a popup appear asking which instance of the debugger you want to attach the process to. The top one should be your cBot code, the second option will be a new VS instance. Pick your cBot.

Your breakpoints should now be hit.

Once done with debugging you can either reverse step 1 or comment out step 2. Personally, I prefer the old version but this is probably a change that came with .NET6 rather than a change that Spotware made.

firemyst since: 26 Mar 2019;

  18 Sep 2022, 09:57

Google and searching the cTrader.com website is your friend:

https://help.ctrader.com/ctrader-automate/debugging/#debugging-a-cbotindicator