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

Isolate "duplicate method names" error

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

    Isolate "duplicate method names" error

    I have a customer that is trying to import our tools and getting the dreaded "duplicate method names" error.

    Usually, it means that they already have an old something of ours imported and they simply need to remove it first (via "Remove NinjaScript Assembly"). Unfortunately, they don't have anything of ours imported (that I can see from a screenshot of their imported list). They have A LOT of other indicators imported, however. About 50 items in their list!

    Is there any way to isolate which "duplicate method" is the one that is causing the issue? Is this something that that appears in the Trace/Log file, etc? Any suggested techniques in determining what needs to be removed on their end, in a sea of indicators?

    Thank you for any help you can provide!

    #2
    Hello neoikon,

    You can try to manually import the item on that PC to see if any errors are presented. That would really be the only way to isolate it down to something specific, otherwise it would likely be suggested to have the user do a clean install and re import just your item. They could then re import any additoonal items they still needed to see where the conflict comes from.

    To manually import the item you would need to extract the zip file and place the .dll and .cs files in the folder: Documents\NinjaTrader 8\bin\Custom
    After adding the files you would need to manually reference the dll file from the NinjaScript editor and compile.
    After that process errors should display, to reverse the process first remove the reference from the list then shut down NinjaTrader and delete the files you added.


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

    Comment


      #3
      I ended up connecting to the customer's machine and importing via the normal way and it gave the "duplicate method" error (I did not see anything of ours installed), so I went through the manual steps you mentioned (copy cs/dll files, add a reference, and rebuild) and it build successfully, without error!

      Why would the normal method of importing the ZIP file fail, but manually coping files work fine? I'm not sure how to solve this issue going forward.

      Thank you!

      Comment


        #4
        Hello neoikon,

        That would be difficult to say without knowing what was in your zip or what the customer already had imported. You could try to reconnect with the user and perform a clean install and then import only your item. That would let you know if this is something they had conflicting or a problem with the zip specifically. I can also test the zip if you want to email it to platform support [at] ninjatrader.com however if only 1 user is having the problem its likely something specific on that machine.

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

        Comment


          #5
          I have an old version of my software that imports just fine, but exporting and importing an updated version now ALWAYS gives the "duplicate method" error, even on a clean NinjaTrader install. What can a vendor do if if an indicator works perfectly on their production machine, then we go through the NinjaTrader export process and use the NinjaTrader import process (on a different machine) and it fails (when manually importing works)?

          I've been dealing with this "duplicate method" issue on and off for about 8 years now (on both NinjaTrader 7 and 8). Is there a comprehensive "try this" list?

          Why can I usually import a new version of an indicator ON TOP of an old version (without removing), but sometimes not?

          Is there a way to determine what the "duplicate method name" actually is?

          Thank you for any help that you can provide.

          Comment


            #6
            Hello neoikon,

            Thanks for the post.

            I reviewed the past details here and wanted to confirm Is this still just the one user having the problem or do you now see this on any other install?

            If you see this in general on any install that's going to be much easier to address because we can test the code being used in that use case to better understand it.

            I've been dealing with this "duplicate method" issue on and off for about 8 years now (on both NinjaTrader 7 and 8). Is there a comprehensive "try this" list?
            There is not necessarily a list of items to try, in most situations reducing the code or using prints can help. This would be a situation where reducing the code is likely going to be needed to try and find what is needed to produce the error to begin with. While that can be a tedious step depending on the amount of code it will be much less time than you have been seeing the problem pop up.


            Why can I usually import a new version of an indicator ON TOP of an old version (without removing), but sometimes not?
            This is going to heavily relate to what you created and what code was used. If you are now seeing this in general and we can test it I can recommend a few steps to allow us to do that.

            The first would be to find the minimal code needed to see the problem, for example if you include multiple items in your export try to make a test export with less of your items. Try one indicator or item as a starting point and see if that produces the error.

            Once you have a general idea of what item/s create the issue, make a export of that as source code and then send that to platform support [at] ninjatrader.com and include a link to this post. I can try exporting the script and see if i get the error, assuming I do I can then look at that code to see if anything sticks out that looks out of place. Depending on the complexity of the code at that point we may or may not be able to reach an answer but that would start the process to which we can find an answer. You may still need to do additional steps like reducing the code further in case there is nothing obviously wrong with what code was used but that is something we can address later.

            As a side note most export are able to be exported and then imported normally between updates so this very likely relates to something specific you are doing in your code. As you noted this has been happening for a long time so that would give me the impression it is part of something you have been doing for a a long time. Potentially the structure you used or where you defined something that you used. Id really need to see the code to make a guess at what the problem may be but you may want to start by looking at the original code you made first.

            Is there a way to determine what the "duplicate method name" actually is?
            Not really unless you tried the manual import steps I previously provided and it actually produces an error in the editor. This is the general error the import compile produces and without the NS editor we cannot see what compile errors may have happened.

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

            Comment


              #7
              Thank you for the detailed reply. As mentioned, I've run into it numerous times on and off over the past 8 years, each time a different reason. Sometimes it's a random user, specific to their machine. Sometimes not.

              In the most recent situation, it was on every import, on every machine. I've determined it's because of bad auto-generated code within the .cs file within the exported ZIP file (incorrect namespaces). I manually fixed it and now it works fine again.

              Comment


                #8
                Hello neoikon,

                If something was generated incorrectly there is no situation where we would suggest to manually edit the .cs file in the resulting zip because that is something you would have to remember to do for every export that contains that problem.

                If you know what area of the .cs is having a problem that will point to something you are doing in your code, if you can provide a sample we can potentially suggest an alternative way to accomplish that correctly so the platform just generates the .cs correct to begin with. After exporting the only modification you may need to do to a zip is add resources like dlls or items you referenced, you shouldn't need to manually edit anything in the zip to work.

                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  If something was generated incorrectly there is no situation where we would suggest to manually edit the .cs file in the resulting zip because that is something you would have to remember to do for every export that contains that problem.

                  Exactly! Tell me about it. I 100% agree and understand the process all too well, but I have to be able to send out my product.

                  As I mentioned, the generated output had the incorrect namespaces for my indicators, so there isn't a specific piece of code to look at or output "Print()", etc.

                  I did determine that if I have a custom namespace (for an enum, for example), if it is ABOVE the "indicator" itself, it breaks the generated output (both generated code inside the indicator and the exported .cs file). Below it, and it seems to work fine (from an initial test).

                  For example, this breaks it:

                  PHP Code:

                  namespace CustomNamespace
                  {
                      public enum 
                  Test {A,B,C};
                  }

                  namespace 
                  NinjaTrader.NinjaScript.Indicators.MYNAME
                  {
                      public class 
                  MyIndicator {...}



                  But this works:

                  PHP Code:

                  namespace NinjaTrader.NinjaScript.Indicators.MYNAME
                  {
                      public class 
                  MyIndicator {...}
                  }

                  namespace 
                  CustomNamespace
                  {
                      public enum 
                  Test {A,B,C};


                  Comment


                    #10
                    Hello neoikon,

                    I did determine that if I have a custom namespace (for an enum, for example), if it is ABOVE the "indicator" itself, it breaks the generated output (both generated code inside the indicator and the exported .cs file). Below it, and it seems to work fine (from an initial test).
                    Right, that's not a valid place to define an enum from within an indicator script. We have a sample of how an enum should be defined and used in the following link. You need to make sure it comes after the class in if defined in an indicator and also that you use the fully qualified name, not using statements.

                    https://ninjatrader.com/support/help...ned_parame.htm

                    Please let me know if I may be of additional assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      You need to make sure it comes after the class in if defined in an indicator
                      I'm not defining it within the indicator class. It's a separate namespace. Yes, I am doing it exactly like your example, but it being above or below should make no difference from a compiler standpoint. That's like saying the order of functions within a class matter.

                      Again, my code works and compiles fine. What is failing is the auto-generated code causing problems.
                      Last edited by neoikon; 10-06-2020, 08:36 AM.

                      Comment


                        #12
                        Hello neoikon,

                        Just to clarify, I had not said class I said within the indicator script or .cs file.

                        NinjaTrader is not a standard C# compiler, it does have specific stipulations on how you design your file in some situations. In the case of indicators there is extra code being generated for those so the structure is very important. That is so NinjaTrader knows how to handle the file and generate the needed code at the bottom correctly. The enum requires specific placement in the file, if its above the class it wont work right, if you use using statements instead of the fully qualified name it wont work right. The sample in the help guide would be the correct way to go about using an enum.

                        Please let me know if I may be of additional assistance.
                        JesseNinjaTrader Customer Service

                        Comment


                          #13
                          Thank you for the clarification. It's disappointing that there are so many minefields to dodge that aren't documented. I spent many hours solving this problem (one, determining that it was an issue with the auto-generate code, and two, how to make the auto-generated code happy).

                          Nowhere on that page you shared nor in the example ZIP file does it say that it's critically important to define the namespaces in that particular order (it's valid C# code either way, so there is no reason for me to assume order matters). How are we supposed to know that?

                          Perhaps the default comment above the namespace (in all example and built-in .cs files) should include a note about this:

                          // This namespace holds all indicators and is required. Do not change it. It's required to be first in the file!
                          namespace NinjaTrader.NinjaScript.Indicators {...}

                          Thank you

                          Comment


                            #14
                            Hello, I was having the same problem and I identified that in the strategy that I was exporting it had a reference to a custom indicator that I was not using in the strategy.

                            I removed the reference, repeated the export and the import worked fine on the computer that had the problem.

                            #region Using declarations
                            using NinjaTrader.NinjaScript.Indicators.NAME; --> Delete the reference to unused indicator

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by habeebft, Today, 07:27 AM
                            1 response
                            11 views
                            0 likes
                            Last Post NinjaTrader_ChristopherS  
                            Started by AveryFlynn, Today, 04:57 AM
                            1 response
                            12 views
                            0 likes
                            Last Post NinjaTrader_Erick  
                            Started by Max238, Today, 01:28 AM
                            4 responses
                            37 views
                            0 likes
                            Last Post Max238
                            by Max238
                             
                            Started by r68cervera, Today, 05:29 AM
                            1 response
                            10 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by geddyisodin, Today, 05:20 AM
                            1 response
                            14 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Working...
                            X