473,320 Members | 1,978 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,320 software developers and data experts.

Using an ActiveX ocx control on a Webform

I have been working on this for several days and am still have had no
success in achieving this. Pleae help. It seems that documentation for this
is very limited. I have looked in several books and they all seem to say
either nothing about this or that this is "out of the scope of this book",
even "Professional ASP.NET".

I have a ActiveX component that I'd like to expose through a .NET wrapper so
in the case that a client browses to my aspx page and does not choose to
download the ActiveX I can Automate the ActiveX object through the .NET
Wrapper on the Server and then stream the result of the ActiveX object
output to the client as a JPG.

Here is all I've done so far:

I've used the AxImp utility to create a new dll, called AxMyActiveX.dll.
I've also asked for it to give me the source code for this type library and
it has and it is called Interop.AxMyActiveX.cs.
I have added this line of code
[System.ComponentModel.ToolboxItemAttribute(true)]
in order to be able to view the "UI" of this ActiveX control to my .cs file
and then used the command line csc to recompile and build the new
Interop.AxMyActiveX.dll.

I create a new ASP.NET webApplication. I have one ASPX page. I browse to my
Interop.AxMyActiveX.dll and set my reference to this dll.
Since .NET is free threated by default and I am attempting to use a COM
component I have set the following attribute
AspCompat="TRUE" (which forces the page to execute in STA mode) in my ASPX
file ( the file into which I am attempting to add my Interop.AxMyActiveX
object).

I switch into Design mode and go to my toolbox and select Add/Remove Items.
I browse to my Interop.AxMyActiveX.dll. The item "AxMyActiveX" appears in
the toolbox but it is GRAYED OUT!

If I try to create the control programmatically from within my page load
event such as below

private void Page_Load(object sender, System.EventArgs e)
{

AxMyActiveXControl AxMyActiveX= new AxMyActiveXControl.AxMyActiveX();

AxMyActiveX.SetSomeProperty = true;

}

and then set an exposed property which takes a bool value I get an exception
thrown such as :

Server Error in '/AFRWS' Application.
----------------------------------------------------------------------------
----

Exception of type InvalidActiveXStateException was thrown.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Windows.Forms.AxHost+InvalidActiveXStateExc eption:
Exception of type InvalidActiveXStateException was thrown.

Source Error:

Line 62:
Line 63:
Line 64: AxMyActiveX.SetSomeProperty = true;
Line 65:
Line 66:

Source File: c:\pathtomyfile.aspx Line: 64

Stack Trace:

[InvalidActiveXStateException: Exception of type
InvalidActiveXStateException was thrown.]
AxMyActiveXControl.AxMyActiveX.set_SetSomeProperty (Boolean value)
PathtoMyFile.Page_Load(Object sender, EventArgs e) in
c:\Pathtomyfile\MyPage.aspx.cs:64
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

I have no idea what I'm doing improperly but I can't get this to work. I
tried using the item in the design mode of a regular .NET Windows Control
Library and I was able to add the item into the toolbox and it was available
(not grayed out). I was able to drag it onto the design window and compile
it as a usercontrol. Then I created a windows application and I was able to
drag this new usercontrol onto the form and everything ran and worked just
fine. Please help!
Thanks so much,
Mehrh


Nov 17 '05 #1
1 3076
Did you ever meet your needs as described below?
I would be very anxious to do the same thing.
Do you have any sample project you can share ?

* * Please include a copy of this message with your reply

Jeff Bennett
Je**@Bennet-Tec.Com

=================== ===================

Mehr H wrote:
I have been working on this for several days and am still have had no
success in achieving this. Pleae help. It seems that documentation for this is very limited. I have looked in several books and they all seem to say either nothing about this or that this is "out of the scope of this book", even "Professional ASP.NET".

I have a ActiveX component that I'd like to expose through a .NET wrapper so in the case that a client browses to my aspx page and does not choose to download the ActiveX I can Automate the ActiveX object through the ..NET Wrapper on the Server and then stream the result of the ActiveX object output to the client as a JPG.

Here is all I've done so far:

I've used the AxImp utility to create a new dll, called AxMyActiveX.dll. I've also asked for it to give me the source code for this type library and it has and it is called Interop.AxMyActiveX.cs.
I have added this line of code
[System.ComponentModel.ToolboxItemAttribute(true)]
in order to be able to view the "UI" of this ActiveX control to my ..cs file and then used the command line csc to recompile and build the new
Interop.AxMyActiveX.dll.

I create a new ASP.NET webApplication. I have one ASPX page. I browse to my Interop.AxMyActiveX.dll and set my reference to this dll.
Since .NET is free threated by default and I am attempting to use a COM component I have set the following attribute
AspCompat="TRUE" (which forces the page to execute in STA mode) in my ASPX file ( the file into which I am attempting to add my Interop.AxMyActiveX object).

I switch into Design mode and go to my toolbox and select Add/Remove Items. I browse to my Interop.AxMyActiveX.dll. The item "AxMyActiveX" appears in the toolbox but it is GRAYED OUT!

If I try to create the control programmatically from within my page load event such as below

private void Page_Load(object sender, System.EventArgs e)
{

AxMyActiveXControl AxMyActiveX= new AxMyActiveXControl.AxMyActiveX();

AxMyActiveX.SetSomeProperty = true;

}

and then set an exposed property which takes a bool value I get an exception thrown such as :

Server Error in '/AFRWS' Application.
---------------------------------------------------------------------------- ----

Exception of type InvalidActiveXStateException was thrown.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Windows.Forms.AxHost+InvalidActiveXStateExc eption: Exception of type InvalidActiveXStateException was thrown.

Source Error:

Line 62:
Line 63:
Line 64: AxMyActiveX.SetSomeProperty = true;
Line 65:
Line 66:

Source File: c:\pathtomyfile.aspx Line: 64

Stack Trace:

[InvalidActiveXStateException: Exception of type
InvalidActiveXStateException was thrown.]
AxMyActiveXControl.AxMyActiveX.set_SetSomeProperty (Boolean value)
PathtoMyFile.Page_Load(Object sender, EventArgs e) in
c:\Pathtomyfile\MyPage.aspx.cs:64
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

I have no idea what I'm doing improperly but I can't get this to work. I tried using the item in the design mode of a regular .NET Windows Control Library and I was able to add the item into the toolbox and it was available (not grayed out). I was able to drag it onto the design window and compile it as a usercontrol. Then I created a windows application and I was able to drag this new usercontrol onto the form and everything ran and worked just fine. Please help!
Thanks so much,
Mehrh


Nov 19 '05 #2

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

Similar topics

0
by: VB Programmer | last post by:
I am going to use an ActiveX control on my webform. 1. How can I set it up so that if a user views the web page and doesn't have the ActiveX control it immediately/automatically downloads it...
1
by: VB Programmer | last post by:
I am going to use an ActiveX control on my webform. 1. How can I set it up so that if a user views the web page and doesn't have the ActiveX control it immediately/automatically downloads it...
2
by: Mehr H | last post by:
I have been working on this for several days and am still have had no success in achieving this. Pleae help. It seems that documentation for this is very limited. I have looked in several books and...
0
by: Kevin Ortman | last post by:
Hi all, I am wondering if the following is a known problem, and if there are any known solutions. Thanks in advance, Kevin Ortman
3
by: EJ1003 | last post by:
Hello I would like to create Activex Control uisng C# and use it in ASP.Net webform. User Control is not solving my requirement so I am going for Activex Control. Please guide me on this, how...
2
by: Wasi Rehman | last post by:
Hello friends, I am facing some problem about ActiveX Control (Build in VB 6.0) , when i add activeX control in WinForm its work fine I can access its attribute and method but when i add the...
7
by: Lau Lei Cheong | last post by:
Hello, I'm using javascript's insertAdjacentHtml() to insert images to the webform at runtime. This runs fine(image successfully displayed at the browser) but when I tried to access the...
3
by: Jeff Beem | last post by:
Hi, I'm a long-time VB/VB.net developer but this is my first web development experience. I've been tasked with hosting/rendering one of my company's ActiveX controls on an ASP.net 2.0 web page....
2
by: deccio | last post by:
I have create an activex Control with Visual studio 2005 and framework 2.0 in c# to add drag & drop functionality to upload multi file. When I use it in a windows form it work fine. Infact if I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.