Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Minor Bug: Cannot access a disposed object

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

    Minor Bug: Cannot access a disposed object

    When running a new strategy:

    1. Right click, New Strategy
    2. Click to select an Instrument
    3. Select a stock symbol which is not in your default list
    4. Click the exchange dropdown.
    5. You get this stack trace and that control does not work properly until you restart NT:

    ************** Exception Text **************
    System.ObjectDisposedException: Cannot access a disposed object.
    Object name: 'ComboBox'.
    at System.Windows.Forms.Control.CreateHandle()
    at System.Windows.Forms.ComboBox.CreateHandle()
    at System.Windows.Forms.Control.get_Handle()
    at System.Windows.Forms.Control.set_CaptureInternal(B oolean value)
    at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ComboBox.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    This happens on 6.0 and I saw it on 6.5 as well.

    #2
    - I can't reproduce
    - not sure about your scenario, do you mean: (3) select "Stock" as instrument type

    Comment


      #3
      Yes, select stock, type in a symbol name, do not tab out of the symbol field, click on the exchange combo box while the symbol field still has focus. I can reproduce this 100% of the time.

      Comment


        #4
        Not reproducible. Looks like a .NET bug, since no NT code involved in call stack.

        - please make sure you have installed latest windows and .NET updates
        - worst case you could go through a complete cycle of
        * uninstall NT
        * uninstall .NET
        * clear browser cache
        * download .NET runtime again: http://www.microsoft.com/downloads/d...displaylang=en
        * install NT again

        All you data would be preserved

        Comment


          #5
          Well I am certainly not going through all that to fix this minor issue, particularly because I suspect it will still be there. I'll just add any symbols I want to trade to my default list as a workaround.

          Comment


            #6
            I'm getting this same error but I'm using Futures. I haven't nailed it down but it just happened twice to me. I've been doing the same thing every day for 2 weeks now and haven't had this bug before.

            Here is my log:

            Code:
            2008-12-16 08:05:04:911 in OnUnhandledThreadException
            2008-12-16 08:05:04:978 ********* exception trapped *********
            2008-12-16 08:05:04:978 Cannot access a disposed object.
            Object name: 'ComboBox'.
            2008-12-16 08:05:04:978    at System.Windows.Forms.Control.CreateHandle()
               at System.Windows.Forms.ComboBox.CreateHandle()
               at System.Windows.Forms.Control.get_Handle()
               at System.Windows.Forms.Control.set_CaptureInternal(Boolean value)
               at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
               at System.Windows.Forms.Control.WndProc(Message& m)
               at System.Windows.Forms.ComboBox.WndProc(Message& m)
               at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
               at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
               at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
            EDIT: I just reran NT and my strategies, this time I didn't click the expiration month, I choose them from my instrument list and I didn't get this problem. So I think it's related to the expiration combo box.
            Last edited by cunparis; 12-16-2008, 07:20 AM.

            Comment


              #7
              Thanks. Recommendation as per post #4 still would apply.

              Comment


                #8
                Originally posted by NinjaTrader_Dierk View Post
                Thanks. Recommendation as per post #4 still would apply.
                But if it were .NET, how could it stop working one day when nothing on the PC has changed. No new software, etc. I have only used this PC for IB & Ninjatrader for the past week.

                Comment


                  #9
                  Sorry I would not know.

                  Comment


                    #10
                    I am getting similar errors when selecting a stock from the Instrument row in the property grid. I can reproduce the error 100% of the time.

                    Repro Steps
                    1. Start a new instance of NinjaTrader.
                    2. Open a new Strategy Analyzer window.
                    3. Right-click "<On the fly>", select "Backtest".
                    4. On my machine at least, the default value for "Instrument" is "ZB 03-09".
                    5. Select the "Instrument" row, and click the dropdown button.
                    6. Click the "Type" dropdown, and select "Stock".

                    At this point, NinjaTrader displays a dialog saying it "has detected a problem and needs to shut down".

                    I checked the log file and found that these steps can result in one of two different exceptions:

                    Code:
                    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
                    at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
                       at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
                       at System.Windows.Forms.Control.DefWndProc(Message& m)
                       at System.Windows.Forms.Control.WmCommand(Message& m)
                       at System.Windows.Forms.Control.WndProc(Message& m)
                       at System.Windows.Forms.ComboBox.WndProc(Message& m)
                       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
                       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
                       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
                    Code:
                    Cannot access a disposed object.
                    Object name: 'Button'.
                    at System.Windows.Forms.Control.CreateHandle()
                       at System.Windows.Forms.Control.get_Handle()
                       at System.Windows.Forms.Control.set_CaptureInternal(Boolean value)
                       at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
                       at System.Windows.Forms.Control.WndProc(Message& m)
                       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
                       at System.Windows.Forms.Button.WndProc(Message& m)
                       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
                       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
                       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
                    In regards to your earlier statement of:

                    Looks like a .NET bug, since no NT code involved in call stack
                    This may indeed be a bug in WinForms (.NET), but it's also possible to cause this type of exception (at least the second one) from user code.

                    Here's a simple example. Say you wrote a custom Button control which did the following:

                    Code:
                    public class MyButton : Button {
                        protected override void OnGotFocus(EventArgs e) {
                            base.OnGotFocus(e);
                            this.Dispose();
                        }
                    }
                    Clicking this button (when it currently doesn't have focus) will generate the exact same "Cannot access a disposed object" exception that I posted above, with no user code on the stack. When using WinForms you need to be careful when creating and disposing Controls. Otherwise you can get strange exceptions, even with no user code on the stack.

                    I wouldn't rule out the possibility of a .NET bug, but I also wouldn't rule out the possibility of a bug in your application code. You may want to take a closer look at your code for the "Instrument" editing dialog.

                    I'm using NinjaTrader 6.5.1000.8 and .NET Framework 3.5 SP1 (2.0.50727.3053).

                    Comment


                      #11
                      Thanks for your research. However, I just performed your steps below on NT 6.5.1000.8 no problem.

                      Comment


                        #12
                        Have you tried it on .NET Framework 3.5 SP1? This version of the .NET Framework includes .NET Framework 2.0 SP2, which contains many changes to 2.0 features like WinForms. It's possible this bug can only be reproduced on .NET 3.5 SP1.

                        Also, what OS are you using? I am using Windows XP SP3.

                        Finally, it's possible this could be a timing-related issue. So if your test machine is faster or slower than my machine you may not be able to repro.

                        A number of people are seeing this issue, so I suspect it is somehow related to your application. Maybe it is a .NET bug, but you are somehow triggering the bug via a certain codepath.

                        Comment


                          #13
                          Same setup as yours: XP SP3 and .NET 3.5 SP1. Please proceed as per my post below to see if that would resolve the issue.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by kujista, Today, 06:23 AM
                          4 responses
                          13 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by traderqz, Yesterday, 09:06 AM
                          2 responses
                          15 views
                          0 likes
                          Last Post traderqz  
                          Started by traderqz, Today, 12:06 AM
                          3 responses
                          6 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by RideMe, 04-07-2024, 04:54 PM
                          5 responses
                          28 views
                          0 likes
                          Last Post NinjaTrader_BrandonH  
                          Started by f.saeidi, Today, 08:13 AM
                          1 response
                          8 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Working...
                          X