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

Reloading Custom.dll after compiling in Visual Studio

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

    Reloading Custom.dll after compiling in Visual Studio

    I am sorry, I have read several similar threads regarding Visual Studio but I could not find quite what I am looking for:

    I would like to work with VisualStudio to develop indicator code. This works quite ok for me but I have problems to make NT reload the DLL after compilation.

    The usual workflow to edit an indicator in the Custom.dll for me is like this:
    1. Use the editor in NinjaTrader to edit code in the indicator
    2. Compile inside the editor
    3. Now I can press F5 in a parallel chart window (that displays the indicator) to refresh the UI using the updated code
    -> Great, I can change/compile the code in one window and I can refresh the graphs while NT is running by just pressing F5 in the chart window

    Now I would like to do the same using Visual Studio. So I created a VisualStudio project which contains all the cs-files from the custom.dll and also added references to NinjaTrader.Core.dll and WilsonORMapper.DLL.
    I can compile the Custom.dll just fine now. But now I have to quit NT, copy my new DLL to "bin\Custom" and then restart NT. Then the code gets accepted and works fine.

    But my question is: Is there any way to "inject" my (in VS) compiled DLL into NT without restarting it? I tried to replace the custom.DLL while NT is running but its not possible because the DLL is in use.

    Big thanks in advance!

    #2
    Hello _vbs_,

    Thank you for writing in. I am not familiar with any way to accomplish this while the file is in use. If you do not want to restart NinjaTrader, you simply need to make sure that you do not have any indicators or strategies running in the platform when you go to overwrite it.

    I recommend working with visual studio by following our official approach as outlined in our help guide here: http://ninjatrader.com/support/helpG...isual%2Bstudio

    Please let me know if I may be of further assistance.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Thanks for the hint. I would like to come back to this though since I switched to NT8 and learned that working with VS was greatly improved there! Thanks for that!

      So working with the Custom.DLL itself works well for me now. But I have added another helper DLL of mine as a reference to the Custom.DLL. Currently when I edit and compile that helper DLL I cannot get NT to reload the changed DLL and take account of the changes.

      So, for example when doing this:
      1. I have a custom indicator (MyInd) to which I added a reference to my util DLL (MyUtil.dll) and I use function "CalculateData()" from it. I copied MyUtil.dll to the NT's folder "bin\Custom". -> It works and I can use "CalculateData()" from "MyInd".
      2. Now inside MyUtil.dll, I rename "CalculateData()" to "ProcessData()" (so I compile it and replace the previous version at "bin\Custom") <- Note: I cannot just replace "bin\Custom\MyUtils.dll" (access denied). But I can rename the existing one (to MyUtil_.dll) and then copy the new one over)
      3. In the NinjaEditor in my indicator MyInd I change the code to reflect the renaming of the function in MyUtil.dll. So I replace the call to "CalculateData()" to "ProcessData()".
      4. Now I hit compile in the NinjaEditor and it works. So, at compilation it seems it picked up the new MyUtil.dll and generated a new NinjaTrader.Custom.dll
      5. But now when I try to run the indicator I get the error (similar to this):
      Code:
      Default Indikator 'MyInd': Error on calling 'OnBarUpdate' method on bar 0: Method not found: "void ProcessData()".
      So obviously when running the indicator the .NET engine still uses the old MyUtil.dll where the function is still named "CalculateData()". At this point I would like to make NT reload MyUtil.dll
      6. When I now shutdown NT and restart then the indicator runs without problems. So it seems I have to restart NT to correctly pick up the new MyUtil.dll.

      So is there any way to make NT pick it up without restarting? If not then I think it would be a worthwhile feature.

      Comment


        #4
        Hello _vbs_,

        Thank you for the update. I will investigate this in greater detail and I will either update this post with steps you can take to avoid restarting, or I will submit a feature request.

        I will update this post as soon as possible. Thank you for your continued patience.
        Michael M.NinjaTrader Quality Assurance

        Comment


          #5
          Hi Michael,

          are there possibly any news on this topic? Having to shutdown and restart NT completely for every code change is really a big deal for me. And I assume some other people might be struggling with this too.

          Any hints are appreciated, big thanks!

          Comment


            #6
            Hello _vbs_

            Thanks for your post.

            In review of your question the answer would be no because all 3rd party references are loaded on application startup and only loaded once. You must restart in order to reload changes from those assemblies.

            Please let us know if you would like this added as a feature request.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thanks for your answer Paul. Yes please, if possible please add this as a feature request. Thanks a lot!

              Comment


                #8
                I just wanted to step in here and see if there is an easier way to accomplish what you are looking for, before I log this request in our system. Are you just looking for a solution to work with your NS files in Visual Studio, and have them compile right away so you can simply reload NS on a chart, etc., just as you could while working in the NS Editor?

                If that's the goal, this is actually much simpler than the process you attempted. All you need to do is open the Custom project in VS, located in Documents/NinjaTrader 8/bin/Custom, then start working with the scripts in the project. When you wish to compile, all you need to do is save the file you are working on in VS. The NinjaScript Editor will automatically detect that a file in the project has changed, and will automatically kick off a compile in 1 or 2 seconds. At that point, you can reload NS on your chart, and continue coding.

                If your use-case is more complex than that, please let me know, and I'll get the request logged so we can start to track demand.
                Dave I.NinjaTrader Product Management

                Comment


                  #9
                  Hi Dave! I know the way you have described and I am using it to edit my NS-strategies inside VisualStudio. I have no problems with it and it is working fine.
                  But my issue is different: I have my own non-NS-utility-libraries which I code and maintain outside NS (in VS). I have added those libraries (compiled DLLs) as a reference to my NS-strategies inside NS. So I am looking for a way to make NS reload those libraries after I have recompiled them inside VisualStudio. But I am not even able to copy those DLLs to the NS-custom directory because the existing DLLs are in use and locked and cannot be overwritten using the Windows Explorer.

                  So I think it would be great if you would add this as a feature request. Many thanks!

                  Comment


                    #10
                    I see now, thank you for clarifying. I'll be happy to log the suggestion so we can start to track demand, and I'll post back with a tracking ID soon. (SFT-1119)
                    Last edited by NinjaTrader_DaveI; 02-01-2016, 10:36 AM.
                    Dave I.NinjaTrader Product Management

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Segwin, 05-07-2018, 02:15 PM
                    14 responses
                    1,789 views
                    0 likes
                    Last Post aligator  
                    Started by Jimmyk, 01-26-2018, 05:19 AM
                    6 responses
                    837 views
                    0 likes
                    Last Post emuns
                    by emuns
                     
                    Started by jxs_xrj, 01-12-2020, 09:49 AM
                    6 responses
                    3,293 views
                    1 like
                    Last Post jgualdronc  
                    Started by Touch-Ups, Today, 10:36 AM
                    0 responses
                    13 views
                    0 likes
                    Last Post Touch-Ups  
                    Started by geddyisodin, 04-25-2024, 05:20 AM
                    11 responses
                    63 views
                    0 likes
                    Last Post halgo_boulder  
                    Working...
                    X