Problem using OCX in code behind

U

Utilisateur1

Hello,
I'm trying to use an OCX written in VC++ 6.0 in an ASPX page.
I've set a reference to it in the project. I can see it in the object
explorer with all of its methods and properties.
So when I try to instanciate the object, I've got the following error :
thread is not STA.
I've so try to import it with AXImp.exe myocx.ocx /source (to get the
wrapper's source). Watching at this code, I remark that it refers the
winform namespace and use it in all the code.
Has anybody idea on how to do that ?
Thanks for your ansers.
 
S

Scott Allen

Try adding AspCompat="true" to your @ Page directive. This will put
the thread into a single threaded apartment (STA) while processing the
page.

Does the OCX have a user interface? It can be dangerous to use in
code-behind on the server side.
 
B

Bruce Barker

your OCX (like vb6 com objects) must be run from an STA thread. you can
create an STA thread to to host it at runtime, or if the hosting page is not
a webserver, set the aspcompat flag, which will force asp.net to use a STA
thread.

you may have another problem, most OCX's expected to hosted in a window,
and tie into the window event loop, this is not supported with asp.net.

-- bruce (sqlwork.com)
 

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

Members online

Forum statistics

Threads
474,001
Messages
2,570,251
Members
46,851
Latest member
CristineKo

Latest Threads

Top