debugging with the new version

Created at 14 Sep 2022, 13:28
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!
EY

eynt

Joined 08.05.2020

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


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


@eynt
Replies

ctid3999979
17 Sep 2022, 12:14 ( Updated at: 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.


@ctid3999979

firemyst
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

 

 


@firemyst