Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 842163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:54:56+00:00 2026-05-15T05:54:56+00:00

I’ve been trying to run the sample project provided with the tutorial at stockbotprogramming

  • 0

I’ve been trying to run the sample project provided with the tutorial at stockbotprogramming http://www.stockbotprogramming.com/sharpcibtutorial1.php , but I keep getting a COMException every time I run the application.

I have the TWS Client running and the sample VB projects provided with the API are able to connect just fine, but when I try to use the C# sample provided by the tutorial then I get the following exception:

An unhandled exception of type
‘System.Runtime.InteropServices.COMException’
occurred in System.Windows.Forms.dll

Th exception happens when I try to add the TWS ActiveX control:

namespace CSharpTutorial1
{

    public partial class Form1 : Form
    {
        private AxTWSLib.AxTws tws;
        public Form1()
        {
            InitializeComponent();         
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            tws = new AxTWSLib.AxTws();
            tws.BeginInit();
            tws.Enabled = true;
            tws.Location = new System.Drawing.Point(32, 664);
            tws.Name = "tws";
            Controls.Add(tws); // <-- EXCEPTION HERE!
            tws.EndInit();
            tws.connect("127.0.0.1", 7496, 0);
            String msg = "Connected to TWS server version " + tws.serverVersion + "at " + tws.TwsConnectionTime;
            MessageBox.Show(msg);
        }
    }
}

The original project was probably done with Visual Studio 2005, but I have Visual Studio 2008 and it automatically converted the project (I’ve been reading that there are some problems there). Does anybody know what could be causing this exception? Any ideas on how to fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:54:57+00:00Added an answer on May 15, 2026 at 5:54 am
    1. Important: Make sure you add the component to the IDE using the visual designer. First right click in the toolbox, click “choose items”, click the COM tab, then check the TWS control. Now using the visual IDE drag this item to the surface of your form. It must be visible in your app. (Don’t create it in the Form1_Load())

    2. Do something like this… (don’t use an IP Address of 127.0.0.1, leave it blank):

    axTws1.connect("", 7496, 0);
    axTws1.reqMktData(0, "AMD", "STK", "", 0, "", "", "SMART", "ISLAND", "USD", "", 0);
    
    1. Last (if you’re using 64-bit Windows) compile the project in 32-bit code. Go to the configuration manager and then create a new profile “x86” and set all the configurations to x86.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 444k
  • Answers 444k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Assuming that you are actually getting the file onto the… May 15, 2026 at 6:39 pm
  • Editorial Team
    Editorial Team added an answer I find Pavel Šavara's jni4net project very useful for this.… May 15, 2026 at 6:39 pm
  • Editorial Team
    Editorial Team added an answer scanf does not work with any object types. If you… May 15, 2026 at 6:39 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.