Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BadImageFormatException when calling ATI from an addon

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

    BadImageFormatException when calling ATI from an addon

    Hi

    I d/l the AddonFramework solution from


    declared the an ATI method through DllImport, add a timer and make the call but it throws.
    Can you please see whats wrong with the attached sample?
    Attached Files

    #2
    Hello tolisss,

    What error are you receiving?

    If you simplify the script, just add a timer, do you get an error?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      If you run the sample attached in my first post you will get a BadImageFormatException see also this screenshot https://www.screencast.com/t/BkKSu3tsZ

      Comment


        #4
        The script is super simple I just added a few lines to your online demo (first post attachment)

        Comment


          #5
          Hello,

          This error can often occur if you are referencing the wrong DLL, for example 32bit or 64 bit.

          Please see the link below for more information,


          Here is more information from MSDN on the BadImageFormatException:
          The exception that is thrown when the file image of a dynamic link library (DLL) or an executable program is invalid.


          Please let us know if you need further assistance.
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            Hi

            Unfortunately from your answer is not clear if you could repro the issue with the attached solution so I assume you couldn't and I will provide the steps I used

            1) Download the AddonFramework solution from

            2) declare the Last method any place you prefer
            Code:
            [DllImport(@"C:\Program Files (x86)\NinjaTrader 8\bin64\NtDirect.dll")]
                    public static extern int Last(string instrument, double price, int size);
            3) call this Last method method inside OnWindowCreated after you have the related chart open
            5) Build the Solution which is already preconfigureed as AnyCpu and will copy file to Bin/Custom
            4) Run "C:\Program Files (x86)\NinjaTrader 8\bin64\NtDirect.dll"
            5) Attach the VS solution to the running instance and open the chart

            one the method is called exception is thrown.
            I also tried to use NTClient assembly however once referenced the project build fails with message
            1>D:\eXpandFramework\Trading\NinjaTraderAddOnProje ct\NinjaTraderAddOnProject\AddOnFramework.cs(97,13 ,97,20): error CS0433: The type 'Globals' exists in both 'NinjaTrader.Client, Version=8.0.7.0, Culture=neutral, PublicKeyToken=d159e9ddc93cec0d' and 'NinjaTrader.Core, Version=8.0.7.0, Culture=neutral, PublicKeyToken=null'
            1>D:\eXpandFramework\Trading\NinjaTraderAddOnProje ct\NinjaTraderAddOnProject\AddOnPage.xaml.cs(822,3 0,822,44): error CS0433: The type 'MarketDataType' exists in both 'NinjaTrader.Client, Version=8.0.7.0, Culture=neutral, PublicKeyToken=d159e9ddc93cec0d' and 'NinjaTrader.Core, Version=8.0.7.0, Culture=neutral, PublicKeyToken=null'
            1>D:\eXpandFramework\Trading\NinjaTraderAddOnProje ct\NinjaTraderAddOnProject\AddOnPage.xaml.cs(1255, 11,1255,35): error CS0433: The type 'Globals' exists in both 'NinjaTrader.Client, Version=8.0.7.0, Culture=neutral, PublicKeyToken=d159e9ddc93cec0d' and 'NinjaTrader.Core, Version=8.0.7.0, Culture=neutral, PublicKeyToken=null'
            1>D:\eXpandFramework\Trading\NinjaTraderAddOnProje ct\NinjaTraderAddOnProject\AddOnPage.xaml.cs(1255, 11,1255,50): error CS0185: 'method group' is not a reference type as required by the lock statement
            1>D:\eXpandFramework\Trading\NinjaTraderAddOnProje ct\NinjaTraderAddOnProject\AddOnPage.xaml.cs(1256, 23,1256,47): error CS0433: The type 'Globals' exists in both 'NinjaTrader.Client, Version=8.0.7.0, Culture=neutral, PublicKeyToken=d159e9ddc93cec0d' and 'NinjaTrader.Core, Version=8.0.7.0, Culture=neutral, PublicKeyToken=null'
            I also tried the same approach with NinjaTrader.Custom.csproj

            Comment


              #7
              Hello tolisss,

              You are not able to call the NT.DLL from inside NinjaTrader. Its not supported or documented. There is an external dll which allows our supported broker partners to interact with the platform, which other users have used for their own programs, but it’s not supported.

              You should be able to do this from an external program. Here is a basic sample, which is not supported.


              Please let us know if you need further assistance.
              Alan P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by benmarkal, Yesterday, 12:52 PM
              3 responses
              22 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by helpwanted, Today, 03:06 AM
              1 response
              17 views
              0 likes
              Last Post sarafuenonly123  
              Started by Brevo, Today, 01:45 AM
              0 responses
              11 views
              0 likes
              Last Post Brevo
              by Brevo
               
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              6 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              244 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Working...
              X