Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with MailKit Integration

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

    Help with MailKit Integration

    Hello everyone,

    I'm developing a NinjaScript strategy that uses MailKit to connect to an IMAP server for processing trading signals via email. The code compiles and runs smoothly in Visual Studio, but I encounter compilation issues in NinjaTrader, mainly related to System.Runtime. Setup:
    • The required DLLs (MailKit, MimeKit) are referenced and placed in Documents\NinjaTrader 8\bin\Custom.
    • All assemblies target .NET Framework 4.8.
    I see errors such as:
    • The type 'CancellationToken' is defined in an assembly that is not referenced.
    • Issues related to System.Threading, System.Runtime, and dependencies not being resolved.

    Has anyone successfully integrated MailKit or faced similar issues? Any suggestions or alternative approaches would be greatly appreciated!

    Thank you!

    #2
    Hello Mag5_Trader,

    Are you getting that error when using specific syntax in the NinjaScript editor or is that only happening once you reference the external library? If that only happens with the library that may be how that library has referenced and used System.Threading in its code. You can use that namespace and CancellationToken type from that namespace in NinjaScript without making any changes besides adding the using statement for System.Threading.

    Comment


      #3
      Hello Jesse,

      many thanks for your reply.

      I'm encountering compilation issues related ty my syntax when attempting to use MailKit functions within the NinjaTrader environment, even though the same code compiles without problems in Visual Studio. Specifically, errors appear when referencing types like CancellationToken and Stream from System.Runtime. I've ensured that System.Runtime is properly referenced, but these types are not being resolved during NinjaScript compilation.

      Example & Errors: Here's a snippet causing the issue: persistentImapClient.Connect(ImapServer, ImapPort, true);
      Errors:
      • Reference to type 'CancellationToken' claims it is defined in 'System.Runtime', but it could not be found (CS7069)
      • Reference to type 'Stream' claims it is defined in 'System.Runtime', but it could not be found (CS7069)

      I'd appreciate guidance on addressing these resolution issues integrating MailKit or similar libraries with NinjaTrader, especially regarding handling such system-level references.

      Comment


        #4
        Hello Mag5_Trader,

        Have you added using statements for all of the namespaces accessed by the 3rd party library?
        (Do you have a using statement for System.Runtime at the top of the script?)
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        37 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        64 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X