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

Compiled Assembly Importing Help

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

    Compiled Assembly Importing Help

    Hello!

    So I have an indicator that uses an Enum. In order to allow this Indicator to use an enough I have defined it in the same namespace as the Indicator. Example,

    The Indicator is in the Namespace NinjaTrader.Ninjascript.Indicators.Test
    I have defined the Enum in the same file just above the class in the same namespace as " public enum TypeEnum{enum1, enum2};"

    Here is Full example below (Using Test names instead of real names):

    namespace NinjaTrader.NinjaScript.Indicators.Test
    {
    public enum TypeEnum {enum1, enum2};

    public class TestIndicator: Indicator
    {​

    When I export to Protected Compilied Assembly and try and import on another machine it give me the error "Error importing Compiled Assembly, *Blah Blah*, The Type or Namespace "TypeEnum" could not be found"

    I am thinking this is a build order issue but haven't worked a ton with DLLs and am not sure how to fix it. Hopefully you guys can help, Let me know.

    Also Ideally my goal was to define all of the indicator enums in one seperate file so that if I want to use this enum on another indicator I don't have to send this specific one as well, I can just send the file with all the enums. Got that to work in Uncompilied assembly but not compilied. Let me know if you can help or where I can go for help.

    Thank you so much in advance.

    Also Let me know if I need to recreate a test file to send to you guys

    #2
    How are you using this enum?

    Do you have any public properties that are using this enum?

    For ex,

    [NinjaScriptProperty]
    public TypeEnum MyEnumVar { get; set; }


    If so, try changing that to,

    [NinjaScriptProperty]
    public
    NinjaTrader.NinjaScript.Indicators.Test.TypeEnum MyEnumVar { get; set; }

    The point is, try using the fully qualified namespace for your enum.

    I've had personal experiences where custom enums had
    errors on import -- the solution was using fully qualified
    namespace for my custom enums, esp in the public
    properties.


    Just my 2˘.

    Last edited by bltdavid; 09-02-2023, 02:28 PM.

    Comment


      #3
      Originally posted by bltdavid View Post
      How are you using this enum?

      Do you have any public properties that are using this enum?

      For ex,

      [NinjaScriptProperty]
      public TypeEnum MyEnumVar { get; set; }


      If so, try changing that to,

      [NinjaScriptProperty]
      public
      NinjaTrader.NinjaScript.Indicators.Test.TypeEnum MyEnumVar { get; set; }

      The point is, try using the fully qualified namespace for your enum.

      I've had personal experiences where custom enums had
      errors on import -- the solution was using fully qualified
      namespace for my custom enums, esp in the public
      properties.


      Just my 2˘.

      That worked like a charm! You are a genius. Follow up question,

      So lets say I have another indicator that I would like to use the same Enum for, Right now with the code that I pasted the Enum is defined in my TestIndicator's DLL.
      So if I was trying to give this second indicator to someone they would need to have the first one already (because it contains the specific enum in that namespace).
      How can I get around this? Uncompiled I just create another file that just says this:

      namespace NinjaTrader.NinjaScript.Indicators.Test
      {
      public enum Enum1 {e1, e2};
      public enum TypeEnum {e1, e2};
      public enum TypeEnum1 {e1, e2, e3, e4};
      }​

      But when I attach that file and my Indicator into the same DLL I get that same error that the Enum Type cannot be found.

      Would I just export this specific file as a DLL in the beginning and then from there have them import all of the indicators?
      Can my Indicator DLLs grab that enum type without having to add a reference in the Editor? (Non Coders may have a hard time adding that reference).

      Again thank you so much bltdavid, appreciate the help

      Comment


        #4
        Hello Vikuno1,

        Thanks for your notes.

        bltdavid is correct in stating that you should use the fully qualified namespace for the custom enum in your script.

        In regards to creating a custom enum in a DLL and referencing that enum in other NinjaScripts, please see this forum thread for detailed information posted by my colleague NinjaTrader_Jesse:
        https://forum.ninjatrader.com/forum/...574#post802574
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          Hello Vikuno1,

          Thanks for your notes.

          bltdavid is correct in stating that you should use the fully qualified namespace for the custom enum in your script.

          In regards to creating a custom enum in a DLL and referencing that enum in other NinjaScripts, please see this forum thread for detailed information posted by my colleague NinjaTrader_Jesse:
          https://forum.ninjatrader.com/forum/...574#post802574
          Thank you for the link and explanation! One more question,

          So I have:
          - A separate Enum file (I can make it DLL or Normal)
          - An indicator that references that Enum like this NinjaTrader.NinjaScript.Indicators.TestFolder.Test Enum MyEnum (Works like a charm)

          I understand that I need to have them download the Enum DLL before they download the indicator that way the indicator can have that reference.

          My issue now is exporting the Indicator as a DLL without the Enum file (It is DLL Currently, but when it is a normal file and I attach it then it is compiled into the indicator DLL which I don't want)

          When I try and export the indicator it tells me that it is missing parts (Which would be the Enum DLL) how do I export just the indicator, even though it references the Enum.

          This could be a stupid question, if so sorry to waste your time. I would just like to structure things so that when another indicator needs to reference/reuse that enum, I don't also have to send the indicator that the enum was defined in.

          Thanks again NinjaTrader_BrandonH

          Comment


            #6
            Hello Vikuno1,

            Thanks for your notes.

            You can either have the client import the enum dll first to ensure the reference exists before importing the other indicators. Or the enum dll can be included as an AdditionalReferences.txt item for each individual zip file.

            This is noted on the forum thread linked in post # 4. From the forum thread:

            You could include the enum dll as an additional reference dll with each zip file if you would like, this would prevent the user from importing multiple zips in a specific order.

            After exporting, you would need to include the assembly with the additional references text file. Also, you will need to append the dll file to your final exports zip files. We have a short guide here: https://ninjatrader.com/support/help..._procedure.htm
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_BrandonH View Post
              Hello Vikuno1,

              Thanks for your notes.

              You can either have the client import the enum dll first to ensure the reference exists before importing the other indicators. Or the enum dll can be included as an AdditionalReferences.txt item for each individual zip file.

              This is noted on the forum thread linked in post # 4. From the forum thread:

              You could include the enum dll as an additional reference dll with each zip file if you would like, this would prevent the user from importing multiple zips in a specific order.

              After exporting, you would need to include the assembly with the additional references text file. Also, you will need to append the dll file to your final exports zip files. We have a short guide here: https://ninjatrader.com/support/help..._procedure.htm
              So I think I understand how to add the additional DLL to the Zip file so that they don't have to install multiple.

              What I am having trouble with is actually exporting the Indicator into DLL. It says that it needs all components of the assembly (which would be the enums) but if I add the enums to the indicators DLL then it will conflict with the already installed Standalone Enum DLL.

              I am probably explaining this poorly, I am sorry. Let me know if I need to take another crack at it.

              Thanks so much for your time NinjaTrader_BrandonH! Especially on the weekend

              Comment


                #8
                Hello Vikuno1,

                Thanks for your notes.

                "You could include the enum dll as an additional reference dll with each zip file if you would like, this would prevent the user from importing multiple zips in a specific order."

                You could add an additional reference to dll in the export to have it included in the AdditionalReferences.txt file.

                In the Export window, click 'add', set the Type drop-down menu to 'References', and add the reference to the dll in your export.


                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_BrandonH View Post
                  Hello Vikuno1,

                  Thanks for your notes.

                  "You could include the enum dll as an additional reference dll with each zip file if you would like, this would prevent the user from importing multiple zips in a specific order."

                  You could add an additional reference to dll in the export to have it included in the AdditionalReferences.txt file.

                  In the Export window, click 'add', set the Type drop-down menu to 'References', and add the reference to the dll in your export.

                  Looks like I was just blind haha! Thank you so much for the help, didn't realize there was a references add option on the export. You are a godsend.

                  I should be able to add the custom DLLs. Hopefully you won't hear from me about that! lol

                  Have a great Labor day and I appreciate you responding and helping on the weekend as well.

                  Comment


                    #10
                    Ok hopefully last question @NinjaTrader_BrandonH​,

                    So I got the enums to work and everything is good.

                    The only thing I am struggling with now is exporting a MarketAnalyzer Column.

                    The scenario is this:
                    User has the Indicator DLL Standalone
                    User wants to import Market Analyzer
                    Market Analyzer was exported with Indicator in it so the files conflict.
                    Solution right now would be to essentially have the use delete the Indicator DLL and Market Analyzer DLL will take care of both.

                    Would rather be able to have:
                    Indicator DLL (Already have)
                    Enum DLL (Already have)
                    Market Analyzer DLL (That references Indicator)

                    I have change the indicator on my machine to a DLL so that I can export it while referencing it but for whatever reason when I try and export the Market Analyzer with references to Indicator DLL and Enum DLL it says "Assembly could not be exported. Please ensure all required components are included"

                    Not sure what it could be missing if it has references to both of the DLLs that it uses but let me know.

                    Again sorry if this is stupid question, just confused.

                    Thanks so much!

                    Comment


                      #11
                      Hello Vikuno1,

                      When you export the market analyzer dll are you using the DLL reference to the indicator and enums? You need to select the references option in the dropdown list in the export menu and select the indicator and enums dlls for references and then manually add them to the zip file after exporting. When importing as long as those dlls have the same name as existing references they should be able to be loaded and the import successful.



                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Jesse View Post
                        Hello Vikuno1,

                        When you export the market analyzer dll are you using the DLL reference to the indicator and enums? You need to select the references option in the dropdown list in the export menu and select the indicator and enums dlls for references and then manually add them to the zip file after exporting. When importing as long as those dlls have the same name as existing references they should be able to be loaded and the import successful.


                        Yes I reference both the enums and the indicator and it still says there is something missing and won't let me export the analyzer. Any ideas?

                        Comment


                          #13
                          Hello Vikuno1,

                          its possible that's how you are referencing types in one of the dlls. I would suggest trying to do the following:

                          Create a new enums script and make a basic enum
                          Create a new indicators script and create a indicator that just plots the close or something simple to tell its working along with referencing the enum.
                          Create the market analyzer column and do something simple like plot the close to confirm its working.including referencing the indicator and enum.

                          Export this in the same way and see if it works. If it does not please provide the 3 .cs files so we can review that simplified sample and see what the correct way to approach that would be.
                          JesseNinjaTrader Customer Service

                          Comment


                            #14
                            Ok same thing happened. I am attaching 3 zips:

                            TestBase3.zip - All 3 files just as .cs (No DLLS​ just the base files)
                            TestEnumDLL.zip - The DLL that contains the Enum only
                            TestIndicatorDLL.zip - The DLL that contains the Indicator only but references the TestEnumDLL

                            What I did to create was:
                            1. Create all 3 base files.
                            2. Export TestEnum DLL
                            3. Import TestEnum DLL
                            4. Export TestIndicator DLL
                            5. Import TestIndicator DLL
                            6. Try and export TestAnalyzer with references to the two DLLs

                            I have the TestEnum and TestIndicator as excluded from Compilation instead of full delete, Not sure if that makes a difference. Everything exports fine and compiles fine when I do that.

                            Let me know if you need anything else! Thank you again

                            Comment


                              #15
                              Hello Vikuno1,

                              The files you attached were not included likely because of the dlls. Add just the .cs files for the files in question and then add the steps you are using to export them including the steps of exporting dlls and re referencing scripts so we can try that.
                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by fx.practic, 10-15-2013, 12:53 AM
                              5 responses
                              5,403 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by Shai Samuel, 07-02-2022, 02:46 PM
                              4 responses
                              94 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by DJ888, Yesterday, 10:57 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by MacDad, 02-25-2024, 11:48 PM
                              7 responses
                              158 views
                              0 likes
                              Last Post loganjarosz123  
                              Started by Belfortbucks, Yesterday, 09:29 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post Belfortbucks  
                              Working...
                              X