AxHost.OcxState - using an ActiveX control without a form

  • Thread starter Thread starter Norvin Laudon
  • Start date Start date
N

Norvin Laudon

Hi,

I have a legacy ActiveX control (circa 1996) which I would like to use in a
C# class, without using a form.

I am getting an exception thrown when I try to set properties on the
control: "An unhandled exception of type 'InvalidActiveXStateException'
occurred in axinterop.finsctllib.dll"

When I put an instance of the control on a form, and look at the
auto-generated code, I see a line (where "serial" is the name of the
control):

this.serial.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("serial.OcxState"))
);

I think this is my problem. In my class, I need to initialize the "OCXState"
property of my control, but I don't have the "resources" variable which the
form has.

So my question: Is there any way to generate a default "OCXState" for the
control?

Thanks,
Norvin
 
I am getting the same problem with another activex control
I am trying to use. It seems that when you add a control at
design time, Visual Studio sets a resource in the form's resx.
The .designer.vb then sets the activex control's .ocxstate
from that resource object and voila, it works from design time.

I, like you, would like to be able to add controls dynamically at
runtime. I have no idea what magic VS is doing to put the
control's ocxstate into the resx, but that is the missing piece
of the puzzle.

EDIT: FYI I am using VB.Net 2005
 
Last edited:
Back
Top