Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 llanqui, Today, 10:32 AM
          0 responses
          1 view
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by StockTrader88, 03-06-2021, 08:58 AM
          45 responses
          3,992 views
          3 likes
          Last Post johntraderuser2  
          Started by TAJTrades, Today, 09:46 AM
          0 responses
          7 views
          0 likes
          Last Post TAJTrades  
          Started by rhyminkevin, Yesterday, 04:58 PM
          5 responses
          62 views
          0 likes
          Last Post dp8282
          by dp8282
           
          Started by realblubb, Today, 09:28 AM
          0 responses
          8 views
          0 likes
          Last Post realblubb  
          Working...
          X