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

COM/DLL object with ASP Reference

markrawlingson
346 Expert 100+
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,sitefoot.asp,sidemain.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.Echo() 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 1095

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

Similar topics

11
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...
5
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: ...
3
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? ...
2
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...
0
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...

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.