473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem using OCX in code behind

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.
Nov 19 '05 #1
2 1320
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.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 6 Oct 2005 14:15:37 +0200, "Utilisateur1"
<de****************@wanadoo.fr> wrote:
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.


Nov 19 '05 #2
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)


"Utilisateur1" <de****************@wanadoo.fr> wrote in message
news:43**********************@news.wanadoo.fr...
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.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
9
by: Morten | last post by:
Hi! I have a problem displaying some values in a datagrid. I have an array that consists of a number of objects. Each object has 2 properties: Name and a list of web addresses. (e.g: Name:...
5
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I...
2
by: Eric | last post by:
I'm trying to dynamically load a user control using on the .NET framework (not Visual Studio). The control was designed in Visual Studio and is named: Disable.ascx The first line is: <%@...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
10
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting company. Everyone that uses it has no problems...
4
by: Ian Meakin | last post by:
I have a page called admin.aspx and it uses admin.aspx.cs as it's code behind file. When developing the application on my localhost using VS.NET i reference thsi file using...
3
by: I am Sam | last post by:
Please help. I'm dying here and pulling out the last few remaining elements of my hair over this. I have built a form that will identify and authenticate users. I keep getting the following...
4
by: Antonio Carpentieri | last post by:
Hi all, in my previous post I've wrong typed some tems.. this is the corrected post. in a aspx page I have a repeater like this: <asp:repeater id=repeaterResults runat="server"...
2
by: Alan Silver | last post by:
Hello, I have a user control that has one .cs file, with several .ascx files that call it. The reason for this is that I can pick whichever of the ..ascx files I want (based on a site owner...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.