• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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, 07: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, 11:08 AM.

                    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 Dagamos, Today, 11:48 AM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_RyanS  
                              Started by kantkant2, Yesterday, 03:20 PM
                              4 responses
                              24 views
                              0 likes
                              Last Post eDanny
                              by eDanny
                               
                              Started by EnveousColnago, Today, 11:50 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by Skyfly1715, 01-20-2020, 03:36 PM
                              4 responses
                              33 views
                              1 like
                              Last Post eDanny
                              by eDanny
                               
                              Started by Cyanez, Yesterday, 05:05 PM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_PaulH  
                              Working...
                              X