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

Untrapped Error Problem

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

    Untrapped Error Problem

    Hello:


    I am presently working on debugging my strategy and I am running across a few issues. My current setup is as follows:
    • Ninja Script Editor is set to debug mode
    • From the NinjaScript Editor, I launch Visual Studio
    • Within Visual Studio I connect to the NinjaTrader process
    • VS is configured to trap all Common Language Run Time Exceptions
    One of the problems I am getting is from an untrapped Error that reads as follows:
    A first chance exception of type 'System.InvalidOperationException' occurred in System.ComponentModel.DataAnnotations.dll
    I do not receive a break point in the code to know exactly where this is coming from. The immediate window is flooded with this message, like the code is running in a loop.


    The error is duplicable and occurs each time when I perform the following actions...
    • Right Click on a chart window
    • Click Strategies
    • Immediate Windows in VS is flooded with the above error
      • No call stack is provided in VS
      • No break in the code actually occurs
    • After about a one min delay, the error quits flooding the immediate window and the Strategies window appears for me to select my strategy to test.
    Since this issue is occurring before I am even able to add my strategy to a chart, I am assuming that maybe something is corrupted on my end that might be causing this. So I did the following:
    • Tried this on a chart nothing other than a data series (no indicators loaded, no custom bars) Still got the error
    • Tried this on the new workspace with a new chart - no change
    • Tried this on a new workspace, new chart, and different instruments, no change
    This issue isn't affecting my ability to debug my strategy other than causing a delay to get the screen to load them.

    #2
    Hello,

    Thank you for the post.

    You may be seeing a caught internal exception in this case if this is not coming by directly using your script specifically. This could also be coming from a different script as you stated this is when you open the menu. When you open the menu all scripts get created and run through the first initial states to populate the menu so it could certainly be something else you have imported.

    You can check if your script is causing this, you would just need to exclude your script from compilation and then re-test the scenario using one of the provided samples. If this still happens you could go as far as doing a clean install to see if this still occurs but if this is not affecting your script in anyway you could likely just ignore it. I do not see this using a clean install on my end.

    Being that the error is listing System.ComponentModel.DataAnnotations this could be caused from an Attribute that is applied to a public property. One item I know that throws an internal error which is caught would be to try and use a Resource that does not exist. This often happens when you copy the included items properties like the SMA's period:
    Code:
    [Display(ResourceType = typeof(Custom.Resource), Name = "Period", GroupName = "NinjaScriptParameters", Order = 0)]
    Which may get modified to:

    Code:
    [Display(ResourceType = typeof(Custom.Resource), Name = "[B]MyPropertyName[/B]", GroupName = "NinjaScriptParameters", Order = 0)]
    In the above example this would throw because there is no Resource named MyPropertyName, the solution is just to remove the ResourceType = typeof(Custom.Resource). You could look into items like this to further address this question and see if it is related or not.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mmckinnm, Today, 01:34 PM
    0 responses
    1 view
    0 likes
    Last Post mmckinnm  
    Started by f.saeidi, Today, 01:32 PM
    0 responses
    1 view
    0 likes
    Last Post f.saeidi  
    Started by traderqz, Today, 12:06 AM
    9 responses
    16 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by kevinenergy, 02-17-2023, 12:42 PM
    117 responses
    2,766 views
    1 like
    Last Post jculp
    by jculp
     
    Started by Mongo, Today, 11:05 AM
    5 responses
    15 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X