Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

try catch Exception

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

    try catch Exception

    Hi guys,
    I'm converting a fairly complex strategy over to NT8. I'm getting a crash of Ninja pretty often. Here is some relevant trace info. It doesn't look obvious to me what is the problem. It discusses a null object reference but look at where that has come from. And it is not handled properly as it crashes Ninja.

    Any ideas?

    Thanks,
    saltminer

    7-11-27 16:44:55:426 Object reference not set to an instance of an object.
    2017-11-27 16:44:55:435 System.NullReferenceException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
    at MS.Internal.TextFormatting.LineServicesCallbacks.R emapLSRuns(IntPtr* plsplsruns, Int32 plsrunCount)
    at MS.Internal.TextFormatting.LineServicesCallbacks.G etGlyphsRedefined(IntPtr pols, IntPtr* plsplsruns, Int32* pcchPlsrun, Int32 plsrunCount, Char* pwchText, Int32 cchText, LsTFlow textFlow, UInt16* puGlyphsBuffer, UInt32* piGlyphPropsBuffer, Int32 cgiGlyphBuffers, Int32& fIsGlyphBuffersUsed, UInt16* puClusterMap, UInt16* puCharProperties, Int32* pfCanGlyphAlone, Int32& glyphCount)
    --- End of inner exception stack trace ---
    at MS.Internal.TextFormatting.TextMetrics.FullTextLin e.FormatLine(FullTextState fullText, Int32 cpFirst, Int32 lineLength, Int32 formatWidth, Int32 finiteFormatWidth, Int32 paragraphWidth, LineFlags lineFlags, FormattedTextSymbols collapsingSymbol)
    at MS.Internal.TextFormatting.TextMetrics.FullTextLin e..ctor(FormatSettings settings, Int32 cpFirst, Int32 lineLength, Int32 paragraphWidth, LineFlags lineFlags)
    at MS.Internal.TextFormatting.TextFormatterImp.Format LineInternal(TextSource textSource, Int32 firstCharIndex, Int32 lineLength, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache)
    at MS.Internal.TextFormatting.TextFormatterImp.Format Line(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak)
    at ActiproSoftware.Windows.Controls.SyntaxEditor.Text Formatting.TextViewLineLayoutGroupFactory.#6lc(ITe xtView #N5b, ITagAggregator`1 #y9b, ITagAggregator`1 #z9b, TextRange #I, Double #hpi)
    at #m3b.#b4b.#8lc(ITextView #N5b, ITagAggregator`1 #y9b, ITagAggregator`1 #z9b, TextRange #I, Double #hpi)
    at #m3b.#b4b.#cmc(ITextView #N5b, ITagAggregator`1 #y9b, ITagAggregator`1 #z9b, Int32 #Oqc, Double #hpi, Double #Dzf, Double #Ezf, Boolean #ipi)
    at #m3b.#c4b.#pmc(ITextView #N5b, ITagAggregator`1 #y9b, ITagAggregator`1 #z9b, Size #Gzf, TextPosition #d9b, Boolean #Hzf, Boolean #ipi)
    at ActiproSoftware.Windows.Controls.SyntaxEditor.Prim itives.EditorView.PerformViewLineLayout()
    at ActiproSoftware.Windows.Controls.SyntaxEditor.Prim itives.EditorView.ArrangeOverride(Size finalSize)
    at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
    at System.Windows.UIElement.Arrange(Rect finalRect)
    at System.Windows.ContextLayoutManager.UpdateLayout()
    at System.Windows.ContextLayoutManager.UpdateLayoutCa llback(Object arg)
    at System.Windows.Media.MediaContext.FireInvokeOnRend erCallbacks()
    at System.Windows.Media.MediaContext.RenderMessageHan dlerCore(Object resizedCompositionTarget)
    at System.Windows.Media.MediaContext.RenderMessageHan dler(Object resizedCompositionTarget)
    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)

    #2
    Hello saltminer,

    Is this the only script that can reproduce the behavior?

    Have you commented out code to find the line that is causing the error?
    If so, what is the line of code that when un-commented will cause a crash?

    The error indicates there is a null value being hit in runtime.

    Are there any null-able types that are not being checked for null in the script?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,
      I have not been able to find the problem. Normally, a null object will create a safely handled Exception that quits the strategy in a well behaved manner, a log entry is created and all is well.
      Not this guy. This crashes Ninja.
      It is the only strategy that does it, therefore something in the script is causing it, but it is causing a platform crash. I was hoping you guys had seen that particular path of the Exception before, and could point me in the right direction.

      saltminer

      Comment


        #4
        Hello saltminer,

        Comment out all logic from the code and leave inputs and variable declarations uncommented. Also leave the declaration of OnStateChange and the setting of defaults and the declaration of OnBarUpdate (but comment out all logic within OnBarUpdate).

        After commenting out the logic, compile and run the code.
        Is NinjaTrader still crashing?

        (edit)
        Also, does your script create a lot of prints in the output window?
        If you comment out the prints specifically are you still able to reproduce the crashing?
        Last edited by NinjaTrader_ChelseaB; 11-28-2017, 02:36 PM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          ok, we'll never know. It was something mysterious in the assembly or instance on the chart. I removed the strategy from the chart and put it back on, and all is well.

          Thanks,
          saltminer.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Island_Boy_Trading, Today, 07:39 AM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by cmarkb, Today, 07:19 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by wjadevries, Today, 03:29 AM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_Jim  
          Started by Oracletrades, Yesterday, 09:10 PM
          1 response
          119 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by ginx10k, Today, 07:04 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X