Interactive Brokes ActiveX API 出现程序集未引用错误

发布于 2024-09-01 00:12:42 字数 630 浏览 2 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋风の叶未落 2024-09-08 00:12:42

抱歉,当我读到错误时,从一开始就应该完全显而易见:

您必须添加对程序集“System.Windows.Forms”的引用

Interactive Brokers ActiveX API 要求应用程序具有对 System.Windows.Forms dll 的引用,而控制台应用程序不包含该引用。我手动添加了参考文献,现在效果很好。或者,您可以创建一个 Windows 窗体应用程序,它应该可以正常工作。

Sorry, it should have been completely obvious from the beginning when I read the error:

You must add a reference to assembly 'System.Windows.Forms'

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文