开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

C# .NET + TWS ActiveX = 'Catastrophic failure' exception?


pjslim99
 

I have connected fine using Java and C++ API to TWS, however using
Visual Studio.NET and C#,
I get

'An unhandled exception of type:
System.Runtime.InteropServices.COMException
occured in mscorlib.dll: Catastrophic failure'

I am doing the following

- Start TWS running locally.
- TWS: Settings->Enable ActiveX and Socket Clients
- Create new C# project
- Solution Explorer: Add Reference: Tws ActiveX Control module
(Tws.ocx)
- Add Button with handler and code:

using TWSLib;

.
.

TwsClass myTws = new TwsClass();
myTws.connect("", 7496);

.
.

- and run the program.

If I call any function or retrieve a property from the ActiveX
control I get the same exception.

Any thoughts? Anyone succesfully got C# + TWS API working?

thanks,
PJ