Interoperation / Office Integration Topics include: COM, P/Invoke (e.g. Win32 API), marshaling, distributed applications, VBA and interacting with office apps

Go Back  Xtreme .NET Talk > .NET > Interoperation / Office Integration > 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown


Reply
 
Thread Tools Display Modes
  #1  
Old 01-14-2012, 11:25 PM
arpitbandi arpitbandi is offline
Newcomer
 
Join Date: Jan 2012
Posts: 1
arpitbandi is on a distinguished road
Default 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown



hi ive an activex made in vb6. Am new to .net and attempting to use it in vb2008. i made a reference to it and added the following code to my form_load

Code:
Dim mycon As New Axpass.Axiepass
        TextBox1.Text = mycon.GetIE()
but when the form loads it gives the error,
Quote:
Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.
i also tried to add it as a control and call the method but it returns "" as the result, though the same method if called from a vb program works fine.. plz help and guide me..
Reply With Quote
  #2  
Old 01-15-2012, 09:11 AM
snarfblam's Avatar
snarfblam snarfblam is offline
Ultimate Contributor

Preferred language:
C#, VB
 
Join Date: Jun 2003
Location: USA
Posts: 2,097
snarfblam will become famous soon enough
Default Re: 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown

Based on what Google has to say, System.Windows.Forms.AxHost.InvalidActiveXStateException is often thrown when you try to access an ActiveX component that is not fully initiailized. (It's hard to do more than guess and Google when I don't know anything about the control in question.)

Not being much of an expert on the subject, if the Axpass.Axiepass class is written as an ActiveX control, I'm wondering whether the problem could be related to the fact that after you instantiate it, you don't place it in a control. After all, you don't get the exception when you place the control on a form.

The empty string that gets returned could likely be a completely separate issue. I have no idea what the function does, how it does it, or whether it does it 100% right. (Just because it works in VB6 doesn't mean everything is 100% kosher. It's possible to do something incorrectly and still have it succeed in certain circumstances.) You can try double-checking the ActiveX source to make sure everything looks spiffy, and you should definitely check and make sure you are using the control exactly the same in .NET that you are in VB6. Maybe there's an initialization method that needs to be called or a property that needs to be set. The .NET WinForms designer may also be setting some properties that the VB6 designer did not, or vice-versa.
__________________
e
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
System.InvalidOperationException thrown by System.Drawing magicRoot Windows Forms 4 02-12-2009 01:38 PM
New to .Net- Imports System.Windows.Forms does not appear LazRazMataz ASP.NET 5 02-19-2005 06:14 AM
'System.Windows.Forms.AxHost' in asp.net realsync ASP.NET 3 03-11-2004 12:34 PM
Access to Windows.System.Forms.Control romanhoehne Windows Forms 1 01-07-2004 07:07 AM
System.Windows.Forms not found Iceplug Windows Forms 8 12-26-2002 09:25 AM

Advertisement:







Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe