0

Here is my code for getting for connecting my application to the RTD server

using System;
using System.Drawing;
using System.Windows.Forms;
using NESTClientLib;

namespace NestToAmi
{
public partial class Form1 : Form
    {
        public static dynamic AmibrokerObj { get; set; }
        public static IScripRTD NestRTDObj { get; set; }
        public Form1()
        {
            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)
        {
             int TopicId = 0;
             object[] SymbolList = new object[2];

             TopicId = 1;
             SymbolList[0] = "nse_cm|ITI-EQ";
             SymbolList[1] = "LTP";

             NestRTDObj.ConnectData(TopicId, SymbolList, true);

        }

        public void button4_Click(object sender, EventArgs e)
        {
            try
            {
                 IScripRTD NestRTDObj = new ScripRTD();      // COM object RTD server
            }
            catch (Exception ex)
            {
                 MessageBox.Show("Nest Trader Interface Error. Check Nest Trader Is Opened or Not \r\n" + ex);
            }
         }
      }
}

I wanted to access NestRTDObj (COM object) created in button4_Click to the button1_Click. Please help me in this case. I tried to access this object as public variable but am doing something wrong.

1 Answer 1

1

In button 4 handler you declare it as a local variable instead of using the class level field. Remove the type name to fix it.

NestRTDObj = new ScripRTD();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.