Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can this get an exception?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How can this get an exception?

    I was trying to create a new chart when, according to Visual Studio, the "panel.MouseMove" line got

    An exception of type 'System.IndexOutOfRangeException' occurred in WindowsBase.dll but was not handled by user code

    Additional information: Index was outside the bounds of the array.
    How is that possible?

    The following code is from the indicator's OnStateChange() method
    Code:
                    case State.DataLoaded:
                        foreach (ChartPanel panel in ChartControl.ChartPanels)
                        {
                            panel.MouseMove += new MouseEventHandler(OnMouseMove);  // <== exception here
                        }
                        break;
    FWIW: While not completely reproducible:
    • This usually (but not always) happens if I move the mouse over the first new chart I create after the workspace comes up
    • I have never seen it happen with a subsequent new chart
    • Perhaps NT has something uninitialized that the first chart often trips over, but that is initialized for any subsequent new charts? (Just a guess.)
    Last edited by ETFVoyageur; 08-07-2016, 07:47 AM.

    #2
    Hello ETFVoyageur,

    So we fully understand why this is occurring, can you please clarify or provide a few items?

    • Does this cause any window in NinjaTrader 8, or the entire program to stop operating
    • Would you be willing to replace the call to OnMouseMove with a call to the following delegate :

      public void OnMouseMoveWithTrace(object sender, System.Windows.Forms.MouseEventArgs e)
      {
      Log("Button : " +e.Button, LogLevel.Information);
      Log("Clicks : " +e.Clicks, LogLevel.Information);
      Log("Delta : " +e.Delta, LogLevel.Information);
      Log("Location: " +e.Location, LogLevel.Information);
      Log("X: " +e.X, LogLevel.Information);
      Log("Y: " +e.Y, LogLevel.Information);
      Log("HashCode: " +e.GetHashCode(), LogLevel.Information);
      Log("Type: " +e.GetType(), LogLevel.Information);
      OnMouseMove(sender, e);
      }
    • Once you have done so, could you send your log and trace files for the day after running your code on a day when this behavior occurs to platformsupport[at]ninjatrader[dot]com, referencing this unique ID number in the body of your e-mail? 1554458

    Thank you in advance, this information will make it easier for us to track down what has occurred.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Jessica,

      Sorry about the delay.

      Hard to say about window problems. When I was having problems I also saw various other exceptions that I could not pin down at all. I was afraid my code was doing something bad since I never saw any problems unless my indicator was in use. I spent a long time trying to isolate what might be causing the problem and eventually stopped because I could no longer reproduce the problem.

      I have just been trying to reproduce the problem for you. My procedure has been to
      • Bring up my workspace
      • Connect to it with Visual Studio
      • Create a new chart (the default template includes my indicator)
      • Move the mouse over the chart as it is getting populated

      I tried 7 times without any problem. On the eighth time I got a
      Win32Exception was unhandled

      An unhandled exception of type 'System.ComponentModel.Win32Exception occurred in WindowsBase.dll
      That is familiar from when this all began -- it was one of 2 or 3 kinds I got while trying to produce the mouse one. When I "Continue" from it NT goes away.

      The most common of this sort was one that said trying to access protected memory, and suggested that memory corruption was a likely cause.

      I just tried another 5 times and saw no problems. The bottom line is that there really is a problem. I cannot say with assurance whether it is NT, my indicator, or something in NT that my indicator is tickling. Unfortunately I do not know how to reliably produce the problem, so I'm not much help narrowing it down. That is aggravated by the fact that the only times I have seen it I have been doing something unusual (for me) -- creating a new chart. Normally I just stick with my workspace's multi-tabbed existing chart.

      I know this is not much help, but I don't know what else to offer.

      --EV

      Comment


        #4
        Hello again ETFVoyageur,

        What you have given us is nearly enough by itself. We can go ahead and get started attempting to reproduce on our end with what we have already. In the meantime though, to enable us to rule out any configuration cause on your end, please send me your log and trace files, templates, and other files.

        You can do this by going to the Control Center-> Help-> Email Support.
        Please reference the following ticket number in the body of the email: 1554458
        IMPORTANT: Please also tick all the boxes in the "Other Files" section.

        This will allow us to reproduce your configuration on our end inside a virtual machine.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Wow! That took a while ... I started a fresh copy of NT and did as you asked. After more than 10 minutes the dialog popped up saying email successfully sent. I hope that helps.

          --EV

          Comment


            #6
            Bad news -- it bounced. What now?
            Code:
            To: <me>
            Subject: Mail delivery failed: returning message to sender
            From: Mail Delivery System <[email protected]>
            Date: Tue, 09 Aug 2016 14:06:54 -0600
            
            This message was created automatically by mail delivery software.
            
            A message that you sent could not be delivered to one or more of its
            recipients. This is a permanent error. The following address(es) failed:
            
              [email protected]
                host mx1.emailsrvr.com [108.166.43.1]
                SMTP error from remote mail server after RCPT TO:<[email protected]>:
                550 5.7.1 <[email protected]>: Relay access denied.
            
            
            Action: failed
            Final-Recipient: rfc822;[email protected]
            Status: 5.0.0
            Remote-MTA: dns; mx1.emailsrvr.com
            Diagnostic-Code: smtp; 550 5.7.1 <[email protected]>: Relay access denied.
            
            To: [email protected]
            Subject: Attn: JessicaP: Support Request
            From: <me>
            Date: 9 Aug 2016 13:06:53 -0700
            
            Please reference the following ticket number in the body of the email: 1554458
            Last edited by ETFVoyageur; 08-09-2016, 05:11 PM.

            Comment


              #7
              I just wanted to confirm, in spite of the message you received, that I was able to receive your installation files. I am currently using a Ninja installation with your configuration in a virtual machine to reproduce this behavior, and will return to this thread when I have more information.
              Jessica P.NinjaTrader Customer Service

              Comment


                #8
                Hello ETFVoyageur,

                I have tried several times, using your configuration, to reproduce this in the version of NinjaTrader that will become NinjaTrader 8 Beta 13, in a 64 bit Windows 10 virtual machine, including pausing and unpausing the machine to generate very fast mouse movements, and was unsuccessful in reproducing this.

                I notice a mention of an indicator in your first post. Would it be possible for you to provide us with a stripped down copy of your indicator's source code that we may use to test with?
                Jessica P.NinjaTrader Customer Service

                Comment


                  #9
                  I'm not surprised --- that is what I would have predicted. I'll email you the indicator and a few comments / suggestions.

                  Comment


                    #10
                    Hello again ETFVoyageur,

                    Since we were unable to reproduce the behavior you observed even with the additional tools you sent us, and since adding custom mouse event handlers is currently outside the scope of our documentation, I would like to treat this as a feature request, and I would like to ask the product management team to produce a supported method as far as adding mouse event handlers. This way, should something like this happen again, the code which produces this behavior will be in-house, and we will be better able to provide support than we are in this case where we are relying primarily on user generated code.

                    I would like to ask, can you generally describe in plain language the use case for adding custom mouse events, and what your mouse event code accomplishes?

                    Otherwise, currently, you may need to refer to the publicly available MSDN documentation on mouse event handlers available here



                    to debug this behavior on your end. I recommend the approach I listed earlier, adding trace code to a user event handler rather than using a built-in event handler, so that key information necessary to reproduce this and understand why it occurs ends up in your log files.

                    I will be taking the liberty of adding this code to the indicator files you sent us for your convenience momentarily.

                    Thank you once more for helping to make NinjaTrader 8 the best product it can be.
                    Jessica P.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_JessicaP View Post
                      I would like to ask, can you generally describe in plain language the use case for adding custom mouse events, and what your mouse event code accomplishes?
                      The indicator displays information about the bar the mouse pointer is on. What is displayed is configurable. Some I find helpful every day, and some helps when debugging certain problems. I need to update that information in two circumstances. One is when the mouse moves to another position on the chart, so I need to catch mouse move events. I'd be happy to use an NT-supported mechanism if there were such a thing. In fact my first instinct was to look for something to override, but I did not find anything.

                      Otherwise, currently, you may need to refer to the publicly available MSDN documentation on mouse event handlers available here



                      to debug this behavior on your end.
                      I'm not currently debugging anything related to that. As far as I now, all is working fine. I don't know what happened in the first place, but it eventually disappeared without my changing any code. Just one of those mysteries of the universe as far as I can tell.

                      I recommend the approach I listed earlier, adding trace code to a user event handler rather than using a built-in event handler, so that key information necessary to reproduce this and understand why it occurs ends up in your log files.

                      I will be taking the liberty of adding this code to the indicator files you sent us for your convenience momentarily.
                      I am looking forward to seeing your suggestion. Thanks.

                      --EV

                      Comment


                        #12
                        Hello ETFVoyageur,

                        You should have received a C# file from me at 12:15 PM EDT . Please let us know if this did not get sent and I can attempt to resend it.



                        I have submitted a feature request to the product management team for the following feature :

                        This user would like NinjaScript supported methods for adding mouse and keyboard events


                        I will follow up with more information as soon as it's available. If the feature requests already exists, a vote will be added to it.


                        Please let us know if there are any other ways we can help.
                        Jessica P.NinjaTrader Customer Service

                        Comment


                          #13
                          I got the email -- thanks.

                          --EV

                          Comment


                            #14
                            Does this hapen without VS attached?

                            Comment


                              #15
                              sledge, any help you can think of would be appreciated.

                              We tried with several "toy" indicators as well as the one the user sent, and were not attempting with VS attached. I should mention that the one the user sent did not have any custom mouse event handlers anywhere, and we needed to continue using "toy" indicators to simulate what this user was experiencing. I suspect given this, that the code which actually contains a call to a mouse event handler on the user's end may have some information in it which will be helpful. This was the motivation behind my suggestion in my first reply.

                              If anyone is able to reproduce this, and give us steps we can use to reproduce this, preferably with products built-in to NinjaTrader and minimal code suitable for posting on the forums, it would be highly appreciated.

                              I would once again like to thank our community for helping to make NinjaTrader 8 be the best product it can be.
                              Jessica P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              59 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X