Hi,
Before I have trid to execute the C# code below to login, I have logged in with the TWS platform and that is up and running.
Now, I am trying to connect with the code below that I use in a Form application but first I receive an exception message for the line Controls.Add(Tws1) that says:
System.Runtime.InteropServices.COMException (0x80040154): Class not registered
If I take that line away, I will instead get this exception message:
Method 'connect' cannot be invoked at this time
I cant understand what is wrong?
Before I have trid to execute the C# code below to login, I have logged in with the TWS platform and that is up and running.
Now, I am trying to connect with the code below that I use in a Form application but first I receive an exception message for the line Controls.Add(Tws1) that says:
System.Runtime.InteropServices.COMException (0x80040154): Class not registered
If I take that line away, I will instead get this exception message:
Method 'connect' cannot be invoked at this time
I cant understand what is wrong?
Code:
private void button1_Click_1(object sender, EventArgs e)
{
try
{
Tws1 = new AxTWSLib.AxTws();
Tws1.BeginInit();
Tws1.Enabled = true;
Tws1.Location = new System.Drawing.Point(32, 664);
Tws1.Name = "Tws1";
Controls.Add(Tws1);
Tws1.EndInit();
Tws1.connect("127.0.0.1", 7496, 0);
String msg = "Connected to TWS server version " + Tws1.serverVersion + " at " + Tws1.TwsConnectionTime;
label2.Text = msg;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}