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
    http://ninjatrader.com/support/helpG...dOnProject.zip

    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,
          http://ninjatrader.com/support/forum...d.php?p=298330

          Here is more information from MSDN on the BadImageFormatException:
          https://msdn.microsoft.com/en-us/lib...exception.aspx

          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
            http://ninjatrader.com/support/helpG...dOnProject.zip
            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.
              http://ninjatrader.com/support/forum...732#post509732

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

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by georgeinharmony, Today, 12:06 AM
              2 responses
              13 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by Prisalice, Yesterday, 07:07 AM
              2 responses
              16 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Futurestrader00, Yesterday, 12:04 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Blairski, Yesterday, 11:26 PM
              0 responses
              10 views
              0 likes
              Last Post Blairski  
              Started by aligator, Yesterday, 02:38 PM
              0 responses
              10 views
              0 likes
              Last Post aligator  
              Working...
              X