Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exception handling

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

    Exception handling

    I'm not sure if this is a ninja or a mysql issue:

    I tried to open a mysql connection by the official c# mysql connector demo code within the NinjaScript Initialize -method:

    MySql.Data.MySqlClient.MySqlConnection conn;

    string myConnectionString;

    myConnectionString = "server=127.0.0.1;uid=root;" +
    "pwd=12345;database=test;";

    try
    {
    conn = new MySql.Data.MySqlClient.MySqlConnection();
    conn.ConnectionString = myConnectionString;
    conn.Open();
    }
    catch (MySql.Data.MySqlClient.MySqlException ex)
    {
    Log(ex.Message);
    }


    Thereafter I got the Message in the Log-File, that Initialize failed, because "AssembyResolveEvent-Handler cannot return ReflectionOnly Assemblys".

    Can exception handling be used within Ninjascript?

    Best Regards

    Thomas

    #2
    Hello Thomas,
    NinjaScript is basically c# and you can use the try catch blocks for exception handling. Please refer to this sample code which further illustrates it.


    SQL is beyond what we can support buy you can refer to this thread which is in similar lines
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hello Joydeep,

      thank you for your support. The error may be caused by a version conflict. I've installed several Net Versions. How can I find out which one is used by the Ninjascript compiler? In the "Assemby Reference" view are the names but no pathes to the system DLLs.

      Best Regards
      Thomas

      Comment


        #4
        Hello Thomas,
        NinjaTrader directs to the .Net Framework 3.5.

        A typical path will be like C:\Windows\Microsoft.NET\Framework64\v3.5\

        You can download the compatible .Net Framework version 3.5 from here
        Microsoft .NET Framework 3.5 Service Pack 1 is a full cumulative update that contains many new features building incrementally upon .NET Framework 2.0, 3.0, 3.5, and includes cumulative servicing updates to the .NET Framework 2.0 and .NET Framework 3.0 subcomponents.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X