Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unhandled exception: Exception has been thrown by the target of an invocation.

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

    Unhandled exception: Exception has been thrown by the target of an invocation.

    I've never had this error condition before...it happens when I start Ninja...I have quite a bit of custom code....but don't know how to debug this since it does not tell me that script object the problem is...

    Ideas??

    Ninja loads and everything seems to work normally... but...well certainly there is a problem...

    #2
    here is the trace file entry...seems there is an object not instantiated...could it have to do with AccountSelector (in the inner stack)

    2024-01-31 16:36:52:914 *************** unhandled exception trapped ***************
    2024-01-31 16:36:52:914 Exception has been thrown by the target of an invocation.
    2024-01-31 16:36:52:914 Object reference not set to an instance of an object.
    2024-01-31 16:36:52:918 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.

    at NinjaTrader.NinjaScript.Indicators.AATrader.AAATM9 9.accountSelectorChanged(Object sender, SelectionChangedEventArgs e)
    at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler, Object target)
    at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target, RoutedEventArgs routedEventArgs)
    at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.RaiseEventImpl(Dependency Object sender, RoutedEventArgs args)
    at System.Windows.Controls.ComboBox.OnSelectionChange d(SelectionChangedEventArgs e)
    at System.Windows.Controls.Primitives.Selector.Select ionChanger.End()
    at System.Windows.Controls.Primitives.Selector.Select ionChanger.SelectJustThisItem(ItemInfo info, Boolean assumeInItemsCollection)
    at System.Windows.Controls.Primitives.Selector.OnSele ctedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.OnPropertyChanged( DependencyPropertyChangedEventArgs e)
    at System.Windows.FrameworkElement.OnPropertyChanged( DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.NotifyPropertyChan ge(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffectiveVal ue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
    at System.Windows.DependencyObject.SetValueCommon(Dep endencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
    at System.Windows.DependencyObject.SetValue(Dependenc yProperty dp, Object value)
    at NinjaTrader.Gui.Tools.AccountSelector.OnSelectedAc countChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.OnPropertyChanged( DependencyPropertyChangedEventArgs e)
    at System.Windows.FrameworkElement.OnPropertyChanged( DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.NotifyPropertyChan ge(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffectiveVal ue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
    at System.Windows.DependencyObject.SetValueCommon(Dep endencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
    at System.Windows.DependencyObject.SetValue(Dependenc yProperty dp, Object value)
    at NinjaTrader.Gui.Tools.AccountSelector.OnDesiredAcc ountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at NinjaTrader.Gui.Tools.AccountSelector.<OnAccountSt atusUpdate>b__13_0(AccountStatusEventArgs e)

    --- End of inner exception stack trace ---
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeIn ternal(Object obj, Object[] parameters, Object[] arguments)
    at System.Delegate.DynamicInvokeImpl(Object[] args)
    at System.Windows.Threading.ExceptionWrapper.Internal RealCall(Delegate callback, Object args, Int32 numArgs)
    at System.Windows.Threading.ExceptionWrapper.TryCatch When(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)​

    Comment


      #3
      Ok, well I found the problem!!

      Thanks

      Comment


        #4
        The problem was that AccountSelector is not populated yet or is null when State=DataLoaded


        accountSelector = chartWindow.FindFirst("ChartTraderControlAccountSe lector") as AccountSelector;

        last_Account = accountSelector.SelectedAccount;

        Comment


          #5
          Also, if there is a forced disconnect (for any reason), AccountSelector is null...cause there is no connection, and thus no account

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          576 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X