Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

InvalidActiveXStateException accessing OCX

Posted on 2003-10-26
3
Medium Priority
?
7,280 Views
Last Modified: 2012-06-27
I'm trying to use an OCX in a C# Windows Form for the first time.  My problem is that I’m getting an InvalidActiveXStateException.

The OCX is one I wrote a couple years ago in C++.  I'm learning C#.

I used the IDE to import the OCX (adding it to the ToolBox and dropping it on a form).
The Object Browser shows the methods correctly.  That says to me that I imported the OCX successfully.

In the code snippet, I use ellipsis (…) for code that’s irrelvant to this question.

public class Form1 : System.Windows.Forms.Form
{
… (ellipsis)
private AxACQUIRELib.AxAcquire axAcquire1;      // this is the OCX wrapper
… (ellipsis)
public Form1()
{
   InitializeComponent();
   this.axAcquire1 = new AxACQUIRELib.AxAcquire();  // Instantiate the wrapper
   this.axAcquire1.Acquire(… (ellipsis));            // Constructor exported by OCX
… (ellipsis)
The constructor call gets the InvalidActiveXStateException.

Two questions:
1.      What am I doing wrong?
2.      Any good references (books or web pages) ?

Thank you.



0
Comment
Question by:josgood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
kellycoinguy earned 1000 total points
ID: 9625397
Obviously, this is a reasonable place to start...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsaxhostinvalidactivexstateexceptionmemberstopic.asp

Have you printed out the specific message you are getting like so?

catch (InvalidActiveXStateException ex)
{
   MessageBox.Show("Invalid ActiveX State Exception",ex.Message);
}

Once you see the message, it might give you a clue as to what specifically is going wrong. Then again, it might not. Good luck in any case.

If all you get is:"Run-time exception thrown : InvalidActiveXStateException - Exception of type InvalidActiveXStateException was thrown." then that's probably not terribly helpful.

This is a bit of text I lifted that might be useful:
"The public properties and methods of an ActiveX control can only be referenced after the ActiveX control has been instantiated and initialized completely; otherwise the AxHost.InvalidActiveXStateException exception is thrown. The AxHost.InvalidActiveXStateException exception class contains the name of the member that made the reference and the member type."

I'm afraid that's all I can contribute to this subject. Good luck!!

-Kelly
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question