Interactive Brokes ActiveX API 出现程序集未引用错误
我正在尝试使用 Interactive Brokers ActiveX API,但遇到了一些问题:
错误CS0012:类型 “System.Windows.Forms.AxHost”是 在程序集中定义的不是 参考。您必须添加参考 组装'System.Windows.Forms, 版本=2.0.0.0,文化=中立, PublicKeyToken=b77a5c561934e089'。
我的代码:
namespace DataFeed.Gateway
{
class IBGateway : IGateway
{
private AxTWSLib.AxTws tws; //<-- the error line
//...
}
}
我有一个控制台应用程序,所以我想知道这是否可能是 ActiveX 无法工作的原因...或者这里还有其他问题吗?也许我应该将 AxTWSlib.dll 添加到 GAC,但我真的需要这样做吗?如果我将 dll 添加为资源,那么我认为不需要将其添加到 GAC 中。
注意:我已将 AxTWSlib.dll 放入项目文件夹中,并将其添加到项目引用中...没有问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,当我读到错误时,从一开始就应该完全显而易见:
Interactive Brokers ActiveX API 要求应用程序具有对 System.Windows.Forms dll 的引用,而控制台应用程序不包含该引用。我手动添加了参考文献,现在效果很好。或者,您可以创建一个 Windows 窗体应用程序,它应该可以正常工作。
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.