I’m attempting to use the Interactive Brokers ActiveX API, but I’m having a little trouble:
error CS0012: The type
‘System.Windows.Forms.AxHost’ is
defined in an assembly that is not
referenced. You must add a reference
to assembly ‘System.Windows.Forms,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089’.
My code:
namespace DataFeed.Gateway
{
class IBGateway : IGateway
{
private AxTWSLib.AxTws tws; //<-- the error line
//...
}
}
I have a console application, so I’m wondering if that might be the reason why ActiveX is not working… or is there something else going on here? Maybe I should add the AxTWSlib.dll to the GAC, but do I really have to? If I add the dll as a resource, then I thought that I don’t need to add it to the GAC.
Note: I’ve dropped the AxTWSlib.dll in my project folder and I’ve added it to the project references… no problems there.
Sorry, it should have been completely obvious from the beginning when I read the error:
An the Interactive Brokers ActiveX API requires that application has references to the System.Windows.Forms dll and a console application does not include the references. I added the references manually and now it works fine. Alternately you can create a Windows Forms Application and it should work fine.