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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        133 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X