473,795 Members | 3,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM/DLL object with ASP Reference

markrawlingson
346 Recognized Expert Contributor
Hello,

So I've got a list of functions written in ASP Classic which I include into every page within my application(s). This file is getting quite big and in most scenarios needs to be called 4-5 times for each page load because of the way I structure my pages (sitehead.asp,s itefoot.asp,sid emain.asp, etc). Thus, i'm trying to compile them as a COM/DLL object and simply create an instance of the object in the global.asa and reference the object's methods and properties on any page.

I've done this. It's working great actually and I've just reduced the server load astronomically in the process which i'm quite pleased with. The problem is, some of the functions use ASP objects like the Session object or the Request object, etc. Those particular functions do not work, well, they do but not in the way I want them to.

I've researched this and added in a reference to the ASP Object Library as well as the COM+ Services Type Library.

So here's the problem:

I create an instance of the object in the global.asa - I make calls to the functions within the class object on any other ASP page and most of them work fine, except for the ones that use ASP objects.

However, when I create an instance of the object in my ASP page directly and make a direct call to the function which uses the ASP code - it works. In other words, if i do it directly on the page rather than creating a global object in the global.asa it's golden.

That's wonderful. However, this means I will have to create an instance of the object in every single one of my ASP pages which defeats the purpose entirely.

I'm sure it has something to do with the way I'm initiating the Response objects, etc

Below is the code, and a small function which uses the asp response object to write out hello world.

Expand|Select|Wrap|Line Numbers
  1.     Public Sub OnStartPage(SC As ASPTypeLibrary.ScriptingContext)
  2.       Set Response = SC.Response
  3.       Set Session = SC.Session
  4.       Set Application = SC.Application
  5.       Set Request = SC.Request
  6.       Set Server = SC.Server
  7.     End Sub
  8.  
  9.     Sub Echo()
  10.         Response.Write "hello world"
  11.     End Sub
  12.  
  13.     Public Sub OnEndPage()
  14.       Set Response = Nothing
  15.       Set Session = Nothing
  16.       Set Application = Nothing
  17.       Set Request = Nothing
  18.       Set Server = Nothing
  19.     End Sub
  20.  
This first call, oApplication.Ec ho() works fine, does what it's supposed to do.. but the second call, oApp.Echo(), throws an error. It's not because the object (oApp) isn't set properly, because it is.. all the other functions work.

Expand|Select|Wrap|Line Numbers
  1.  
  2. 'The global.asa object creation...
  3. <OBJECT id="oApp" progid="oApplication.oApp" runat="server" scope="application"></OBJECT>
  4.  
  5. 'the test page to call functions from the object
  6. <%
  7. Set oApplication = Server.CreateObject("oApplication.oApp")
  8. oApplication.Echo()
  9. Set oApplication = Nothing
  10. oApp.Echo()
  11. %>
  12.  
Hope someone can give me a hand here.

Thanks

Sincerely,
Mark
Jan 22 '08 #1
0 1110

Sign in to post your reply or Sign up for a free account.

Similar topics

11
9273
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
5
2521
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj);
3
2775
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Defining_Functions doesn't actually give any insight.
2
2659
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
275
12412
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
10435
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...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
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
9037
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
7538
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
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
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...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.