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

Tried to add 3rd party DLL / crashes immediately

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

    Tried to add 3rd party DLL / crashes immediately

    Hi,

    I tried to put a third party reference DLL for use in NT and now have a mess. Upon opening it's crashing, so I'm not sure if there's some output that I can find to send without getting the program to open up.

    I added the reference in a Strategy folder, which I now see from this post was incorrect, (https://ninjatrader.com/support/foru...ion#post801604) but now I can't seem to get in to change anything. I removed the reference to the new class in Visual Studio and moved some files around, so I wonder if that's causing an issue as well. Before it said it could not create a strategy and then threw an unhandled exception before crashing. Now when I try to launch NT it just dies immediately without any error notification.

    Please help! Thanks.

    #2
    Hello mohawkTrader,

    Thank you for your post.

    Just to clarify a bit, what are you trying to achieve exactly? Are you just trying to install a strategy that was created by a third party or are you creating a script yourself that needs to use the third party DLL? I'm just trying to better understand if this is more a scripting-related request or a general technical support inquiry so that we can direct your request to the correct party.

    If you remove the .dll file that you added to the Strategies folder, are you able to launch the platform successfully?

    I look forward to your response.
    Zachary S.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      I am trying to call a custom 3rd party library (not NT related code) to use in my own strategy. So as strategy file which will call the 3rd party DLL. I was developing in Visual Studio, and it seemed like it was compiling fine when I added a dependency. When I read some of the forums, I realized that this was not the correct approach, but that I needed to add the DLL.

      I added back the DLL into the bin/Custom folder, but out of the Strategies folder, and now I see this upon start-up. It's saying it couldn't find the strategy that I was testing out.

      Comment


        #4
        Here's the rest of the error message, plus the indication of the unhandled exception. Thanks.
        Attached Files

        Comment


          #5
          Hello mohawkTrader,

          Thank you for your response.

          I will have one of our Scripting Support technicians take a look at this thread and they will follow up with you as soon as they can.

          Thank you in advance for your patience.
          Zachary S.NinjaTrader Customer Service

          Comment


            #6
            Hello mohawkTrader,

            We have moved your thread to the Strategy Development forum as your question pertains to NinjaScript development, and not a general technical support inquiry.

            Please make sure that your .NET 4.8 compatible DLL, with all of its dependencies, are added in the Documents\NinjaTrader 8\bin Custom folder, with references added in from within the NinjaScript Editor. (You can right click within the NinjaScript Editor and select References to add more references.)

            From there, please make sure you can compile, and then implement any code which would use these added DLL's in a test script within the NinjaScript Editor.

            I suggest doing this first before developing with Visual Studio just to keep things simple.

            I can't help with using external code, but if you are having trouble adding some specific DLL's please elaborate on which DLL's you are adding and where you got them, we may be able to provide further insight.

            If you are stuck getting the platform started, you can consider setting up in a clean environment, and once you get things sorted there, you can pull out the DLL's from existing environment, and any scripts throwing errors, and then add your script, DLL's and references from the test environment.

            Clean Environment Test:

            Creating a clean environment can be done by following the steps below:
            1. Close NinjaTrader 8, and rename the "NinjaTrader 8" folder in My Documents to something like: "NinjaTrader 8 OLD" Do not delete this folder.
            2. Uninstall NinjaTrader from the Windows Control Panel
            3. Delete the C:\Program Files (x86)\NinjaTrader 8 folder
            4. Reinstall using the installer from http://ninjatrader.com/PlatformDirect
            5. Add your intended DLL's, references, and set up a simple test script. Once this works, roll back your changes to your existing environment and bring in what you have implemented here.
            If you ever need to switch back to your original platform, you may do so by closing NinjaTrader and swapping the platform folder names.

            For example, Close NinjaTrader and rename the new "NinjaTrader 8" folder to "NinjaTrader 8 NEW" and the "NinjaTrader 8 OLD" folder to "NinjaTrader 8." Then restart the platform. Simply put: NinjaTrader 8 will always load the "NinjaTrader 8" folder in My Documents.

            We look forward to assisting.
            JimNinjaTrader Customer Service

            Comment


              #7
              Thanks Jim,

              I guess that seems a little extreme. I don't understand how I will be able to get my old setup back if it just crashes at the beginning as it has been doing. Won't it just do the same when I point it back to the old folder? Meanwhile I am re-installing (for a second time) and will try the new clean test environment in order to see if I can get the third party references to work correctly, then I'll move on to trying to get my old environment back again, then add the new working libs to it.

              Could you elaborate any further on where the error thrown is coming from in the start-up script? Is it looking for a file containing that class which it can't find? Any further instructions down that line would be appreciated too. Thanks.

              Comment


                #8
                So I have the new environment working somewhat, and I'm able to test the new library DLL as explained above. So thanks for that. It looks like part of the issue is how I was trying to create and set a DLL lib object in the class declaration (class is a Strategy subsclass). But if I just declare the new DLL class in the Strategy class declaration, and then set the value in the State.Configure region, things seem to be okay. Otherwise I get a lot of hanging, the strategy analyzer crashed, etc.

                So I'll be able to do some debugging with the DLL in this new environment, but I need my old other indicators / strategies etc. in order to fully test (and obviously I want my old environment back). So, again, any suggestions to get reset on that would be great.

                Thanks.

                Comment


                  #9
                  You can try this procedure:

                  Exit NinjaTrader.
                  Make backup of your Config.xml file
                  Your Config.xml file is at "Documents\NinjaTrader 8\Config.xml"

                  Start Notepad.
                  Open your Config.xml.
                  Find the "<References>" tag.

                  You should see a list of assembly filenames.
                  Do you see the offending assembly filename that you tried to add?
                  If yes, delete that line, save the file, exit Notepad, restart NinjaTrader.
                  If no, exit Notepad, must be something else, bummer.

                  See attached for what the "References" section looks like.
                  Attached Files

                  Comment


                    #10
                    Hello mohawkTrader,

                    I would need more details for what specifically was added, and the script used to give more specifics, but the matter would involve a DLL that is added, the reference for that DLL, and the script that uses that DLL.

                    Figuring out how the setup should be will help to know what you need to do with the original platform folder, which is where the clean environment setup can come in handy.

                    Getting the original platform folder up and running will involve removing the reference for the DLL and the DLL used, as well as the script. bltdavid points out where references are made in the Config.xml file, and you can remove the references from there when the platform is closed.

                    If you need help getting the original platform folder back up, it would be best to assist with that over remote support. Please send a message to platformsupport [at]ninjatrader [dot] com with the text "Attn Jim 3173725" and a link to this thread so we can schedule a time where I may get connected to help out with that.

                    Let us know if there is anything else we can do to help.



                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by bltdavid View Post
                      You should see a list of assembly filenames.
                      Do you see the offending assembly filename that you tried to add?
                      If yes, delete that line, save the file, exit Notepad, restart NinjaTrader.
                      Also, before restarting NinjaTrader, for a super deep clean,
                      remove file "Documents\NinjaTrader 8\workspaces\_Workspaces.xml".

                      Or better,
                      just move the file out of the workspaces folder, such as to your desktop.
                      If NinjaTrader comes up cleanly, you can exit NT, move your original file
                      back, and start NT again -- the point is to test if anything in your current
                      _Workspaces.xml file is tickling the problem.

                      Comment


                        #12
                        As a heads up for the removal of the _Workspaces.xml file trick to prevent opening workspaces on start up, this is something that worked for NinjaTrader 7 but does not apply to NinjaTrader 8. If you want to start NinjaTrader without opening any workspaces, you can temporarily move your workspace xml files out of Documents\NinjaTrader 8\workspaces\ to a safe place on your desktop when the platform is closed. After starting NinjaTrader, the workspace will not be loaded, and any NinjaScripts that are added in the workspace will not be loaded.

                        A final note with strategies, these are saved in the NinjaTrader database file. (Documents\NinjaTrader 8\db\NinjaTrader.sdf) The workspace file will contain a strategy ID associating a chart with a running strategy, but if the strategy is just added to the Control Center, there would be no trace of it in the workspace file and it will be loaded from the database. Renaming the database file when the platform is closed will prevent those strategies from loading since a new database file will be generated.

                        If you do need hands on help recovering an damaged platform folder, please reach out to me over email so we can schedule remote support.
                        JimNinjaTrader Customer Service

                        Comment


                          #13
                          Thanks for the ideas. Just finally had time to give it try but without success. Still just getting unhandled exception. I'll be reaching out directly for help. Thanks again.

                          From my original post, is there somewhere else beside the workspace or config.xml files where the script could be called from. I tried removing it from the project file and deleted the script file, so I figured that it wouldn't be "looking" for it. It's like it's pre-compiled somewhere else. If I could get a fresh re-compile, maybe it would work? Also note, the script was being run from the strategy analyzer, not from a chart or from the control panel.

                          Otherwise I'll await direct support.
                          Last edited by mohawkTrader; 07-09-2021, 01:15 PM.

                          Comment


                            #14
                            Originally posted by NinjaTrader_Jim View Post
                            As a heads up for the removal of the _Workspaces.xml file trick to prevent opening workspaces on start up, this is something that worked for NinjaTrader 7 but does not apply to NinjaTrader 8. If you want to start NinjaTrader without opening any workspaces, you can temporarily move your workspace xml files out of Documents\NinjaTrader 8\workspaces\ to a safe place on your desktop when the platform is closed. After starting NinjaTrader, the workspace will not be loaded, and any NinjaScripts that are added in the workspace will not be loaded.
                            Thanks, but isn't that the same thing as my suggestion?


                            Comment


                              #15
                              Thanks bltdavid . That's basically correct, the problem was that it's not just the file: _Workspaces.xml which apparently is a kind of placeholder. The other named workspace files in the folder (in my case a named workspace Equities.xml) that must be removed also. It creates a new _Workspaces.xml file each time on start-up, but it was still crashing as it attempted to load the latest workspace available (which was Equities.xml). As that was a "corrupt" workspace, or calling the offending scripts, it continually would crash. Thanks again for pointing in this direction.

                              Also, before restarting NinjaTrader, for a super deep clean,
                              remove file "Documents\NinjaTrader 8\workspaces\_Workspaces.xml".

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by selu72, Today, 02:01 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Zachary  
                              Started by WHICKED, Today, 02:02 PM
                              2 responses
                              12 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by f.saeidi, Today, 12:14 PM
                              8 responses
                              21 views
                              0 likes
                              Last Post f.saeidi  
                              Started by Mikey_, 03-23-2024, 05:59 PM
                              3 responses
                              51 views
                              0 likes
                              Last Post Sam2515
                              by Sam2515
                               
                              Started by Russ Moreland, Today, 12:54 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Working...
                              X