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

Determine if running 64-bit or 32-bit Ninja

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

    Determine if running 64-bit or 32-bit Ninja

    Hi,

    I'm trying to determine if the Ninja program running is 32-bit or 64-bit. Normally I'd use System.Environment.Is64BitProcess, but System.Environment doesn't seem to work in Ninja script editor. Is there another way I can do this?

    Thanks

    #2
    Got it!

    System.IntPtr.size

    Thanks.

    Comment


      #3
      I didn't need this in the end. It seems Ninja is copying files at startup to help organize the 32 vs. 64 bit issue. I don't know if it's documented somewhere but I thought I'd just document what I found here.

      I have an external C++ dll that I need to access. I have both a 32-bit and 64-bit version. Normally you don't need to worry about this because 32-bit and 64-bit DLLs are in different directories, but Ninja wants everything in the bin/Custom directory. So I was trying to switch DLLs depending on which version of Ninja I was in:

      if ( is64bit)
      {
      use 64-bit DLL
      }
      else
      {
      use 32-bit DLL
      }

      But instead, you take your 32 bit DLL (bob.dll) and rename it to bob.X86.dll. Take your 64-bit DLL (bob.dll) and rename it to bob.X64.dll. Put them both in the bin/Custom directory. When you start 32-bit Ninja it copies bob.X86.DLL to bob.dll. If you now start 64-bit Ninja it copies bob.X64.dll to bob.dll. So your Ninja code can just use bob.dll and it will always be correct.

      I'm sure everyone else knows this, but I didn't!

      Comment


        #4
        This is a very interesting find -- thank you for sharing.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Originally posted by bubblegum View Post
          I didn't need this in the end. It seems Ninja is copying files at startup to help organize the 32 vs. 64 bit issue. I don't know if it's documented somewhere but I thought I'd just document what I found here.

          I have an external C++ dll that I need to access. I have both a 32-bit and 64-bit version. Normally you don't need to worry about this because 32-bit and 64-bit DLLs are in different directories, but Ninja wants everything in the bin/Custom directory. So I was trying to switch DLLs depending on which version of Ninja I was in:

          if ( is64bit)
          {
          use 64-bit DLL
          }
          else
          {
          use 32-bit DLL
          }

          But instead, you take your 32 bit DLL (bob.dll) and rename it to bob.X86.dll. Take your 64-bit DLL (bob.dll) and rename it to bob.X64.dll. Put them both in the bin/Custom directory. When you start 32-bit Ninja it copies bob.X86.DLL to bob.dll. If you now start 64-bit Ninja it copies bob.X64.dll to bob.dll. So your Ninja code can just use bob.dll and it will always be correct.

          I'm sure everyone else knows this, but I didn't!
          I am glad that you have discovered this, but I did not realize that your intent was to get the correct dll in place. The method you have outlined is how we package protected indicators for distribution.
          Last edited by koganam; 03-06-2016, 08:28 AM. Reason: Corrected spelling.

          Comment


            #6
            Hi,

            I don't know if I'm allowed to ask this here but... this no longer seems to work in NinjaTrader 8. It isn't copying the files at startup. So, is there another way of doing this in NinjaTrader 8?

            Thanks

            Comment


              #7
              Maybe there's a NT specific way... But you could try System.Environment.Is64BitProcess.

              Comment


                #8
                Originally posted by koganam View Post
                I am glad that you have discovered this, but I did not realize that your intent was to get the correct dll in place. The method you have outlined is how we package protected indicators for distribution.
                It's how NinjaTrader does it as well.

                Are you creating the distribution differently?

                I mean, in NT7, when I go through Export NinjaScript and select, say bob.cs, and choose "export compiled assembly", NinjaTrader creates bob.zip containing bob.X86.dll and bob.X64.dll -- all automatically.

                The file bob.zip is then imported by recipients using "Import NinjaScript" menu option.

                I've always thought the checkbox "Protect compiled assemblies" is relatively immaterial to this DLL creation process.

                Originally posted by bubblegum View Post
                So, is there another way of doing this in NinjaTrader 8?
                Have you investigated the differences between export & import between NT7 and NT8?

                Think about it this way:
                Your initial post seemed to be a re-discovery of what NT7 was already doing during the Export sequence. So, perhaps following the Export/Import dance footsteps of NT8 would lead to an equally fruitful discovery?

                Comment


                  #9
                  Helloooo. Any from NinjaTrader got an answer? Thanks.

                  Comment


                    #10
                    Originally posted by bubblegum View Post
                    Normally I'd use System.Environment.Is64BitProcess, but System.Environment doesn't seem to work in Ninja script editor.
                    Let's go back.

                    What do you mean by "doesn't seem to work"?
                    Can you be more specific?
                    Can you post some example code?

                    Which "Ninja script editor" are you referring to?
                    NT7 or NT8?
                    Last edited by bltdavid; 03-08-2016, 12:08 PM.

                    Comment


                      #11
                      Just to reiterate. This is what was working in NT7. It no longer works in NT8.

                      Originally posted by bubblegum View Post
                      I didn't need this in the end. It seems Ninja is copying files at startup to help organize the 32 vs. 64 bit issue. I don't know if it's documented somewhere but I thought I'd just document what I found here.

                      I have an external C++ dll that I need to access. I have both a 32-bit and 64-bit version. Normally you don't need to worry about this because 32-bit and 64-bit DLLs are in different directories, but Ninja wants everything in the bin/Custom directory. So I was trying to switch DLLs depending on which version of Ninja I was in:

                      if ( is64bit)
                      {
                      use 64-bit DLL
                      }
                      else
                      {
                      use 32-bit DLL
                      }

                      But instead, you take your 32 bit DLL (bob.dll) and rename it to bob.X86.dll. Take your 64-bit DLL (bob.dll) and rename it to bob.X64.dll. Put them both in the bin/Custom directory. When you start 32-bit Ninja it copies bob.X86.DLL to bob.dll. If you now start 64-bit Ninja it copies bob.X64.dll to bob.dll. So your Ninja code can just use bob.dll and it will always be correct.

                      I'm sure everyone else knows this, but I didn't!

                      Comment


                        #12
                        Originally posted by bubblegum View Post
                        Just to reiterate. This is what was working in NT7. It no longer works in NT8.
                        Have you tried using System.Environment.Is64BitProcess in NT8?

                        Comment


                          #13
                          That isn't the question.

                          Perhaps someone from NinjaTrader can answer.

                          Comment


                            #14
                            Originally posted by bubblegum View Post
                            It no longer works in NT8.
                            Define "it".

                            Comment


                              #15
                              Originally posted by bubblegum View Post
                              Hi,

                              I'm trying to determine if the Ninja program running is 32-bit or 64-bit. Normally I'd use System.Environment.Is64BitProcess, but System.Environment doesn't seem to work in Ninja script editor. Is there another way I can do this?

                              Thanks
                              I think we may have veered way off course on this one. On my side, Is64BitProcess is still usable in NinjaTrader 8, as it is a part of .NET rather than any NinjaScript class. Can you please clarify what is happening when you try to check this property in the NinjaScript Editor? Are you seeing any compile errors, or not receiving the value you expect when checking the property?
                              Dave I.NinjaTrader Product Management

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              45 views
                              0 likes
                              Last Post jeronymite  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              7 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              10 responses
                              181 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X