Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error with Visual Studio

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

    Error with Visual Studio

    Hello,
    I'm trying to debug a Backtest with Visual Studio.
    When I run the backtest normally, it finish correctly, and the log tab is clean, but when I attach the Visual Studio, and run the Backtest, the VS crash with the next exception:

    System.NullReferenceException
    HResult=0x80004003
    Message=Object reference not set to an instance of an object.
    Source=NinjaTrader.Core
    StackTrace:
    at NinjaTrader.NinjaScript.NinjaScriptBase.SetState(S tate state)
    at NinjaTrader.Gui.NinjaScript.StrategyRenderBase.Set State(State state)
    at NinjaTrader.NinjaScript.NinjaScriptBase.Finalize()
    I've followed this help https://ninjatrader.com/support/help..._debugging.htm

    Could you point me how to find the error?

    Thank you in advance.

    #2
    Hello ruina,

    Are you able to reproduce using the SampleMACrossover included with NinjaTrader?

    Are you using NinjaTrader 8.0.25.0?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,
      the version is 8.0.24.1 64-bit, with VS 2019

      Running SampleMACrossover ends with the same error, but it enters in OnBarUpdate method, my Strategy not.

      Comment


        #4
        Hello ruina,

        Try updating to 8.0.25.0 and see if the error still occurs.
        Access step-by-step NinjaTrader platform training for desktop, web, and mobile. Explore video tutorials and practical guides to help you confidently use trading tools and features.


        What version of visual studio are you using?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          The same error with version 8.0.25.0 and MACrossover.

          The Visual Studio version is: Microsoft Visual Studio Community 2019 Version 16.10.3

          But two-three weeks ago I've tested and it worked, and I have not updated anything. It's weird.

          Comment


            #6
            Hello ruina,

            You may try a full uninstall and re-install of Visual Studio and a clean environment for NinjaTrader.

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              If I've attached VS, and I compile from NT, I've got the same Exception. Only compile, not run.

              Then it looks like the problem is with VS, but I've installed VS 2022, opened the solution, attach to NT, and I've run the backtest with the same result.

              Maybe the issue is with some windows update, do you have a site with issues with the windows updates?

              Comment


                #8
                Hello ruina,

                May I confirm this was with a new NinjaTrader environment folder?

                I'm not aware of any windows update that would cause this behavior. If you do start removing updates and find one that resolves, I would like to note this in our internal tracking software.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Yes, I confirm that is a new environment folder in the folder
                  I've installed a new NinjaTrader in my PC, and clean the folder
                  C:\Users\MyUserName\Documents\NinjaTrader 8

                  Now, when I've attached the NinjaTrader process, the error is:
                  An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module.
                  But I don't have time to run the backtest, it appears only with attach the process from VS. It's weird.

                  Comment


                    #10
                    Hello ruina,

                    This sounds like it might be an installation issue with Visual Studio.

                    Try uninstalling and re-installing Visual Studio 2019 and .NET as suggested in post #6.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      I remember having a similar problem, and yes, it was solved by re-installing Visual Studio.

                      Comment


                        #12
                        I've reinstalled the NinjaTrader and it works.

                        Reading this post in stackoverflow about the C# exception, the third answer talks about "Use Managed Compatibility Mode", then I've remembered that the first time that I've attached VS, I didn't enabled the "Debug Mode" in NinjaScript Editor. It looked like a wrong compiled dll.

                        After that, now I can run and debug the initial code.

                        Thanks to all.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by NullPointStrategies, 03-13-2026, 05:17 AM
                        0 responses
                        101 views
                        0 likes
                        Last Post NullPointStrategies  
                        Started by argusthome, 03-08-2026, 10:06 AM
                        0 responses
                        156 views
                        0 likes
                        Last Post argusthome  
                        Started by NabilKhattabi, 03-06-2026, 11:18 AM
                        0 responses
                        84 views
                        0 likes
                        Last Post NabilKhattabi  
                        Started by Deep42, 03-06-2026, 12:28 AM
                        0 responses
                        57 views
                        0 likes
                        Last Post Deep42
                        by Deep42
                         
                        Started by TheRealMorford, 03-05-2026, 06:15 PM
                        0 responses
                        73 views
                        0 likes
                        Last Post TheRealMorford  
                        Working...
                        X