Crashed in ChartArea.MouseUp with SecurityException: Request failed.

Created at 04 Sep 2020, 01:59
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!
FA

fang0092

Joined 08.06.2019

Crashed in ChartArea.MouseUp with SecurityException: Request failed.
04 Sep 2020, 01:59


Hi. I can't seem to print out elements inside the list.

                        var temp_list = new List<dynamic>();
                        temp_list.Add(new List<dynamic> 
                        {
                            "abc",
                            "def",
                            "ghi",
                            "jkl"
                        });
                        string sentence = "this is a sentence";
                        temp_list.Add(sentence);
                        temp_list.Add("isn't that a phrase?");

                        string type_templist = temp_list.GetType().ToString();

                        foreach (var higher_than_item in temp_list)
                        {
                            if (higher_than_item.GetType().ToString() == "System.Collections.Generic.List`1[System.Object]")
                            {
                                foreach (var item in higher_than_item)
                                {
                                    // this print statement and the one below seems to be causing the error. temporarily made into a comment. help. ->     Print(item);
                                }
                            }
                            else
                            {
                                // one of the print statement to be causing the error. temporarily made into a comment. help. ->     Print(higher_than_item);
                            }
                        }

 


@fang0092
Replies

firemyst
04 Sep 2020, 02:52

RE:

fang0092 said:

Hi. I can't seem to print out elements inside the list.

                        var temp_list = new List<dynamic>();
                        temp_list.Add(new List<dynamic> 
                        {
                            "abc",
                            "def",
                            "ghi",
                            "jkl"
                        });
                        string sentence = "this is a sentence";
                        temp_list.Add(sentence);
                        temp_list.Add("isn't that a phrase?");

                        string type_templist = temp_list.GetType().ToString();

                        foreach (var higher_than_item in temp_list)
                        {
                            if (higher_than_item.GetType().ToString() == "System.Collections.Generic.List`1[System.Object]")
                            {
                                foreach (var item in higher_than_item)
                                {
                                    // this print statement and the one below seems to be causing the error. temporarily made into a comment. help. ->     Print(item);
                                }
                            }
                            else
                            {
                                // one of the print statement to be causing the error. temporarily made into a comment. help. ->     Print(higher_than_item);
                            }
                        }

 

If this is in an Indicator or Bot, you have to give it full security access to print the object and its underlying properties:

    [Indicator(IsOverlay = false, AccessRights = AccessRights.FullAccess)]

If you're not using Visual Studio to debug, you should also try using exception handling to catch your errors and print out the exception which should hopefully help you in the future:

foreach (var item in higher_than_item)
                    {
                        // this print statement and the one below seems to be causing the error. temporarily made into a comment. help. -> 
                        try {
                                Print(item);
                            }
                        catch (Exception e)
                        {
                            Print(e.ToString());
                        }
                    }

 


@firemyst

fang0092
04 Sep 2020, 08:51

RE: RE:

firemyst said:

If this is in an Indicator or Bot, you have to give it full security access to print the object and its underlying properties:

    [Indicator(IsOverlay = false, AccessRights = AccessRights.FullAccess)]

 

This made it work. Thank you. 


@fang0092

... Deleted by UFO ...

... Deleted by UFO ...