Using server-side OCX control with ASP.Net Web Service

  • Thread starter Thread starter las
  • Start date Start date
L

las

(Originally posted to framework.aspnet.webservices, but I am casting a
larger net and trying again)

I am using a library supplied by a third-party vendor. Although the
library has no UI, the vendor supplies it as an .OCX control.

I need to utilize this library in an ASP.Net Web Service. My Web
Service does not expose the OCX control's functionality directly, but
utilizes the OCX for its own internal purposes.

What is the best approach here?

Since I am more familiar with old VB6 than with .Net, I was thinking of
wrapping the OCX with an ActiveX server written in VB6. This ActiveX
server would provide the hidden form that the OCX requires. I would
then utilize the ActiveX server from ASP.Net via interop.

Does this make sense? How would I do this using just .Net -- without
getting VB6 involved?

TIA!
Lee
 
you have a couple issues. asp.net webservices do not support sta com objects
(like ones built in vb6). you should host then in com+, or create your own
sta thread that manages calls to the ocx.

-- bruce (sqlwork.com)
 
Don't use VB6! Just add a reference to this OCX. In solution explorer,
right click "References" and add it.

Wait, the control requires a form?? In a web service? Won't work.
 
Thanks for the heads-up on STA! I had threading in the back of my mind
but had not yet gotten around to researching it -- maybe I was just
afraid of what I would find <grin>
 
Sure it does, all you have to do is set the "aspcomp" attribute to true at
the page level.

Willy.

| you have a couple issues. asp.net webservices do not support sta com
objects
| (like ones built in vb6). you should host then in com+, or create your own
| sta thread that manages calls to the ocx.
|
| -- bruce (sqlwork.com)
|
|
|
|
| | > (Originally posted to framework.aspnet.webservices, but I am casting a
| > larger net and trying again)
| >
| > I am using a library supplied by a third-party vendor. Although the
| > library has no UI, the vendor supplies it as an .OCX control.
| >
| > I need to utilize this library in an ASP.Net Web Service. My Web
| > Service does not expose the OCX control's functionality directly, but
| > utilizes the OCX for its own internal purposes.
| >
| > What is the best approach here?
| >
| > Since I am more familiar with old VB6 than with .Net, I was thinking of
| > wrapping the OCX with an ActiveX server written in VB6. This ActiveX
| > server would provide the hidden form that the OCX requires. I would
| > then utilize the ActiveX server from ASP.Net via interop.
| >
| > Does this make sense? How would I do this using just .Net -- without
| > getting VB6 involved?
| >
| > TIA!
| > Lee
| >
|
|
 
Bruce,

Reviewing the @Page directive, it looks like it can only be used on ASP
Web Forms.

Can aspcompat be set for a web service, or is there something
comparable for a web service?

Thanks,
Lee
 
| Bruce,
|
| Reviewing the @Page directive, it looks like it can only be used on ASP
| Web Forms.
|
| Can aspcompat be set for a web service, or is there something
| comparable for a web service?
|
| Thanks,
| Lee
|

You are right, it only applies to web application not web services. Web
services cannot handle STA threads nor should you ever try to run OCX
components in web applications at all, there isn't such a thing like server
type OCX's , even if they don't have an UI, they have at least one hidden
window and this window's message queue need to be pumped and dispached.
Nothing in the web framework will do this for you, this result in high
memory consumption leading to process recyling and possible deadlocks.


Willy.
 
I just got a communication from the vendor -- it seems their OCX can be
instantiated without a hidden window.

That good news solves the hidden window nastiness described by Willy,
but I guess I still must resolve the STA issue.

I've got some custom connection pooling issues to deal with too, so
I'll probably bundle the STA and connection pooling solutions together.
Looking into COM+ now, but I may just fall back on my old-school roots
and create an out-of-process activeX server.

Thanks Bruce and Willy for your feedback,
Lee
 
Back
Top