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

Using An AcitveX 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
2 1771
ActiveX and putting wrapper is only for server side code access. The activex
has to used the old fashioned way only when it comes to browsers. Jus go to
the html view and code it (clsid:........) the usual stuff.

So i think u wud have to make an ie embedded winform user control fm
scratch.

"Mehr H" <wo********@hotmail.com> wrote in message
news:Ok**************@TK2MSFTNGP12.phx.gbl...
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 #2
Thanks for the response Rajesh but i think you misunderstood my explanation.
I am in fact trying to access this activex on the server side. In the case
that a client wants to download the activex i let them download the COM OCX.
Mehr

"Rajesh.V" <> wrote in message news:eE**************@TK2MSFTNGP11.phx.gbl...
ActiveX and putting wrapper is only for server side code access. The activex has to used the old fashioned way only when it comes to browsers. Jus go to the html view and code it (clsid:........) the usual stuff.

So i think u wud have to make an ie embedded winform user control fm
scratch.

"Mehr H" <wo********@hotmail.com> wrote in message
news:Ok**************@TK2MSFTNGP12.phx.gbl...
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 #3

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

Similar topics

1
by: Newbie | last post by:
Hello! I am working with 2 webforms. The first webform has a 2 weborm textboxes that I use as a placeholders. The second webform is a popup window that has a DataGrid in it. The DataGrid has 2 ...
5
by: KJ | last post by:
This is kind of hard to explain but I have a The controls are created with CreateChildControls(). Now let say I click a button and an error occurs in the control. If I throw it up it goes back...
9
by: Peter Afonin | last post by:
Hello: I need to clear all textboxes on the webform after the data has been submitted. How can I do this in one step? I found a C# code: // get a reference to your form control Control frm...
1
by: Rahim | last post by:
i want to change all the label control style Properties, server control properties at runtime how should i call all the label at runtime, which is present at webform, any collections???? i...
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...
3
by: duff | last post by:
Hiya, I'm trying to replace the commented out code below with a neater version using the IAttributeAccessor interface (so that I don't have to write 'if' statements for all control types). At...
3
by: Joe | last post by:
Hello All, I am developing a webform which creates ArrayLists of people's names and addresses (the values are retrieved from an xml file) and dynamically drops a user control onto the webform...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
0
by: Johnny M | last post by:
I have a form in Access 2003 with WMPlayer.OCX.7 control on a form that plays an .asf file. I open it from another form with a command button that loads the appropriate file and the file starts and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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...

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.