AxHost.OcxState - using an ActiveX control without a form

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
 
Joined
Jun 6, 2008
Messages
1
Reaction score
0
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:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top