473,852 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hello. I posted this problem in the
microsoft.publi c.dotnet.langua ges.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(){TES T.Flower myFlower = new TEST.Flower();
return myFlower.get_Ge tFlower(2);}

And in my form I do "<% Response.Write( GetFlower()); %>" But I get
null because varibles in the COMs "CFlower::OnPag eStart(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.GetFlo wer(2));"
and it works fine.

Does "new TEST.Flower();" not call "OnPageStart(.. .)" function
automatically like "Server.CreateO bject("TEST.Flo wer");" does? The
TEST.dll is added to the ASP.NET/C# pages and intellisence sees all my
methods. Small Note: when I do "myFlower.GetFl ower(2);" C# tells me
to use the direct accessor method "myFlower.get_G etFlower(2);". Could
this be why "OnPageStart(IU nknown* piUnk);" isn't being called?
I don't mind calling the "OnPageStart(IU nknown)" 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 1717
OnPageStart is only called from HttpServerUtili ty.CreateObject , which is what
you should use.

if you want to call OnPageStart yourself, use:

[DllImport("webe ngine.dll")]
internal static extern int AspCompatOnPage Start(
[MarshalAs(Unman agedType.Interf ace)] 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.publi c.dotnet.langua ges.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(){TES T.Flower myFlower = new TEST.Flower();
return myFlower.get_Ge tFlower(2);}

And in my form I do "<% Response.Write( GetFlower()); %>" But I get
null because varibles in the COMs "CFlower::OnPag eStart(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.GetFlo wer(2));"
and it works fine.

Does "new TEST.Flower();" not call "OnPageStart(.. .)" function
automatically like "Server.CreateO bject("TEST.Flo wer");" does? The
TEST.dll is added to the ASP.NET/C# pages and intellisence sees all my
methods. Small Note: when I do "myFlower.GetFl ower(2);" C# tells me
to use the direct accessor method "myFlower.get_G etFlower(2);". Could
this be why "OnPageStart(IU nknown* piUnk);" isn't being called?
I don't mind calling the "OnPageStart(IU nknown)" 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...@di scussions.micro soft.comwrote:
OnPageStart is only called from HttpServerUtili ty.CreateObject , which is what
you should use.

if you want to call OnPageStart yourself, use:

[DllImport("webe ngine.dll")]
internal static extern int AspCompatOnPage Start(
[MarshalAs(Unman agedType.Interf ace)] 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.publi c.dotnet.langua ges.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(){TES T.Flower myFlower = new TEST.Flower();
return myFlower.get_Ge tFlower(2);}
And in my form I do "<% Response.Write( GetFlower()); %>" But I get
null because varibles in the COMs "CFlower::OnPag eStart(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.GetFlo wer(2));"
and it works fine.
Does "new TEST.Flower();" not call "OnPageStart(.. .)" function
automatically like "Server.CreateO bject("TEST.Flo wer");" does? The
TEST.dll is added to the ASP.NET/C# pages and intellisence sees all my
methods. Small Note: when I do "myFlower.GetFl ower(2);" C# tells me
to use the direct accessor method "myFlower.get_G etFlower(2);". Could
this be why "OnPageStart(IU nknown* piUnk);" isn't being called?
I don't mind calling the "OnPageStart(IU nknown)" 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)Se rver.CreateObje ct("TEST.Flower ");
//TEST.Flower myFlower =
(TEST.Flower)Ac tivator.CreateI nstance(Type.Ge tTypeFromProgID ("TEST.Flower") );
return myFlower.get_Ge tFlower(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::OnPageS tart(...) {...}" function are null. This is the
ASP.NET/C# pages. The old pages are ASP.NET/JScript.NET and when they
call Server.CreateOb ject 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
"AspCompatOnPag eStart(...)" function you gave. I'm calling it like
so

-----Inside the Code Behind File (before the "return
myFlower.get_Ge t ...")-----
AspCompatOnPage Start(myFlower) ;
//AspCompatOnPage Start("TEST.Flo wer");
//AspCompatOnPage Start(Server.Cr eateObject("TES T.Flower"));
//AspCompatOnPage Start(myFlower. GetHash());
//myFlower.OnStar tPage(...) //... = Top 4 repeated

The AspCompatOnPage Start always returns "1", and the
"myFlower.OnSta rtPage(Object piUnk)" returns void. None of them seem
to call the "CTEST::OnPageS tart(...) {...}" 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
10705
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. When I modified the file I also stopped and restarted the web server. Can anyone give me some ideas as to why it is not firing? Thanks
3
2309
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 WebApplication1 { using System;
5
2501
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 IE, the session end & application end event are not firing even though i put the break point there. Could u give me the solution for this how i could trace those.
7
4590
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 data was actually being edited. I am using bound textbox controls on the form. Could that have anything to do with it? Does anyone know how to stop the RowChanging events from firing? Thanks!
28
10287
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 appropriate based on your method names . the GridView has OnRowCommand="GridView1_RowCommand" in the aspx. my problem is that the RowCommand event is firing twice (95% of the time) on the page. the other 5% it only fires once. there's no
19
10222
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 app using web application projects and it's firing fine but it was upgraded from the 1.1 framework. Why doesn't my global.asax application_error routine fire?
6
28183
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 RowDataBound event to set the commandargument of the delete button. The event is being fired and works fine. When I press the delete button, the RowCommand event is not firing! and neither is the RowDeleting (the button's commandName is...
4
4211
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 controls as custom server controls and don't understand why this event won't fire. I figured if the creation of the control was in the init, it would be initialized and have its event handlers set up, then after Load, the control would call its...
2
2170
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 realized that the new DocType being used in 2.0 (<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">) is the culprit. Upon using the old 1.1 DocType (<!DOCTYPE HTML PUBLIC...
0
9898
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9748
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11020
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10735
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10356
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9506
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7907
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5736
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.