Solved

InvalidActiveXStateException accessing OCX

Posted on 2003-10-26
3
7,261 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
3 Comments
 
LVL 1

Accepted Solution

by:
kellycoinguy earned 250 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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