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

COMs OnPageStart() Not Firing when using ASP.NET/C#

Hello. I posted this problem in the
microsoft.public.dotnet.languages.csharp origionally but moving it
here since I think it probably belongs here now.

I have a blank ASP.NET/C# page with a code behind file. I made the
following function in the code behind file

public string GetFlower(){TEST.Flower myFlower = new TEST.Flower();
return myFlower.get_GetFlower(2);}

And in my form I do "<% Response.Write(GetFlower()); %>" But I get
null because varibles in the COMs "CFlower::OnPageStart(IUnknown*
piUnk) {...}" method isn't getting set. I have old ASP.NET/
JScript.NET pages that call the function like so "var myFlower =
Server.Create("TEST.Flower"); Response.Write(myFlower.GetFlower(2));"
and it works fine.

Does "new TEST.Flower();" not call "OnPageStart(...)" function
automatically like "Server.CreateObject("TEST.Flower");" does? The
TEST.dll is added to the ASP.NET/C# pages and intellisence sees all my
methods. Small Note: when I do "myFlower.GetFlower(2);" C# tells me
to use the direct accessor method "myFlower.get_GetFlower(2);". Could
this be why "OnPageStart(IUnknown* piUnk);" isn't being called?
I don't mind calling the "OnPageStart(IUnknown)" manually but I'm
unable to find what they want as the arg "IUnknown piUnk". My ASP.NET
Code behind file extends System.Web.Page so I think I should have the
"piUnk" they want someplace... I tried giving it a random number or
string but it just throws an exception.
Any help would be much apprisiated.
NB
Dec 19 '07 #1
2 1689
OnPageStart is only called from HttpServerUtility.CreateObject, which is what
you should use.

if you want to call OnPageStart yourself, use:

[DllImport("webengine.dll")]
internal static extern int AspCompatOnPageStart(
[MarshalAs(UnmanagedType.Interface)] object comobj);

where obj is the com component.

if your component is apartment model (STA), then be sure the page is set as
AspCompat mode, or you will run into threading issues.
-- bruce (sqlwork.com)
"NvrBst" wrote:
Hello. I posted this problem in the
microsoft.public.dotnet.languages.csharp origionally but moving it
here since I think it probably belongs here now.

I have a blank ASP.NET/C# page with a code behind file. I made the
following function in the code behind file

public string GetFlower(){TEST.Flower myFlower = new TEST.Flower();
return myFlower.get_GetFlower(2);}

And in my form I do "<% Response.Write(GetFlower()); %>" But I get
null because varibles in the COMs "CFlower::OnPageStart(IUnknown*
piUnk) {...}" method isn't getting set. I have old ASP.NET/
JScript.NET pages that call the function like so "var myFlower =
Server.Create("TEST.Flower"); Response.Write(myFlower.GetFlower(2));"
and it works fine.

Does "new TEST.Flower();" not call "OnPageStart(...)" function
automatically like "Server.CreateObject("TEST.Flower");" does? The
TEST.dll is added to the ASP.NET/C# pages and intellisence sees all my
methods. Small Note: when I do "myFlower.GetFlower(2);" C# tells me
to use the direct accessor method "myFlower.get_GetFlower(2);". Could
this be why "OnPageStart(IUnknown* piUnk);" isn't being called?
I don't mind calling the "OnPageStart(IUnknown)" manually but I'm
unable to find what they want as the arg "IUnknown piUnk". My ASP.NET
Code behind file extends System.Web.Page so I think I should have the
"piUnk" they want someplace... I tried giving it a random number or
string but it just throws an exception.
Any help would be much apprisiated.
NB
Dec 19 '07 #2
On Dec 19, 12:49 pm, bruce barker
<brucebar...@discussions.microsoft.comwrote:
OnPageStart is only called from HttpServerUtility.CreateObject, which is what
you should use.

if you want to call OnPageStart yourself, use:

[DllImport("webengine.dll")]
internal static extern int AspCompatOnPageStart(
[MarshalAs(UnmanagedType.Interface)] object comobj);

where obj is the com component.

if your component is apartment model (STA), then be sure the page is set as
AspCompat mode, or you will run into threading issues.

-- bruce (sqlwork.com)

"NvrBst" wrote:
Hello. I posted this problem in the
microsoft.public.dotnet.languages.csharp origionally but moving it
here since I think it probably belongs here now.
I have a blank ASP.NET/C# page with a code behind file. I made the
following function in the code behind file
public string GetFlower(){TEST.Flower myFlower = new TEST.Flower();
return myFlower.get_GetFlower(2);}
And in my form I do "<% Response.Write(GetFlower()); %>" But I get
null because varibles in the COMs "CFlower::OnPageStart(IUnknown*
piUnk) {...}" method isn't getting set. I have old ASP.NET/
JScript.NET pages that call the function like so "var myFlower =
Server.Create("TEST.Flower"); Response.Write(myFlower.GetFlower(2));"
and it works fine.
Does "new TEST.Flower();" not call "OnPageStart(...)" function
automatically like "Server.CreateObject("TEST.Flower");" does? The
TEST.dll is added to the ASP.NET/C# pages and intellisence sees all my
methods. Small Note: when I do "myFlower.GetFlower(2);" C# tells me
to use the direct accessor method "myFlower.get_GetFlower(2);". Could
this be why "OnPageStart(IUnknown* piUnk);" isn't being called?
I don't mind calling the "OnPageStart(IUnknown)" manually but I'm
unable to find what they want as the arg "IUnknown piUnk". My ASP.NET
Code behind file extends System.Web.Page so I think I should have the
"piUnk" they want someplace... I tried giving it a random number or
string but it just throws an exception.
Any help would be much apprisiated.
NB- Hide quoted text -

- Show quoted text -
Thanks for your very fast reply :) I still seem to have some
problems. I've tried the following

-----Inside the Code Behind File-----
public void GetFlower() {
//TEST.Flower myFlower = new TEST.Flower();
TEST.Flower myFlower =
(TEST.Flower)Server.CreateObject("TEST.Flower");
//TEST.Flower myFlower =
(TEST.Flower)Activator.CreateInstance(Type.GetType FromProgID("TEST.Flower"));
return myFlower.get_GetFlower(2);
}

-----Inside the Default.aspx-----
<% Response.Write(GetFlower()); %>
All 3 ways I assign "myFlower" seem to act identical. They call the
method in the COM I want, but the values set in the
"CTEST::OnPageStart(...) {...}" function are null. This is the
ASP.NET/C# pages. The old pages are ASP.NET/JScript.NET and when they
call Server.CreateObject it works fine (OnPageStart(...) values get
set); however, I do not wish to make new pages in JScript.NET since
Visual Studio doesn't support it, thus harder to create with the IDE.

I don't think I'm giving the right param to the
"AspCompatOnPageStart(...)" function you gave. I'm calling it like
so

-----Inside the Code Behind File (before the "return
myFlower.get_Get ...")-----
AspCompatOnPageStart(myFlower);
//AspCompatOnPageStart("TEST.Flower");
//AspCompatOnPageStart(Server.CreateObject("TEST.Flo wer"));
//AspCompatOnPageStart(myFlower.GetHash());
//myFlower.OnStartPage(...) //... = Top 4 repeated

The AspCompatOnPageStart always returns "1", and the
"myFlower.OnStartPage(Object piUnk)" returns void. None of them seem
to call the "CTEST::OnPageStart(...) {...}" method since it still
returns my "___ Object is Null" message.
If you have any throughts on some things I could try I'd be very
greatful. Right now I can just set the values I need in a
"if(value==null) *set value*" at the top of the Flower method and that
work s(since I'm only using 1 method at the moment in the C# pages).
However the COM has hundreds of methods and they all have the same
problem as above with the C# pages. The COM has to stay working with
the JScript.NET pages so I'd like to keep the OnPageStart method there
and have C# use that if its possible.

Thanks Again
NB
Dec 20 '07 #3

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

Similar topics

12
by: qaz | last post by:
For some reason my global.asa file is not firing. I have it located in the root of my website (e.g., wwwroot\mywebsite\global.asa) and I have the web site configured as an "application" in IIS. ...
3
by: Mike | last post by:
Hi, I am adding controls dynamically in a WebForm, but none of these controls' events fire. Here is the class code I am using. I have tried so many things, but nothing works :-( namespace...
5
by: Raghu Raman | last post by:
HI, am using a simple project in asp.net using c#. if i put the break point in the application start & session start event , they are firing good .BUT WHEN i close my project while running on...
7
by: Denise | last post by:
I just realized the DataTable_RowChanging events were firing when I called Fill method of the DataAdapter! It fires TWICE for each row loaded. I thought these were only supposed to be called when...
28
by: Tim_Mac | last post by:
hi, i'm new to .net 2.0, and am just starting to get to grips with the gridview. my page has autoEventWireUp set to true, which i gather is supposed to figure out which handlers to invoke when...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
6
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the...
4
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my...
2
by: Sam | last post by:
While attempting to get my floating toolbar to work in ASP.NET 2.0, I noticed that the onscroll event is not firing. I've specified this on the BODY tag, as always. After some testing, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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...

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.