Hi Andy,

Unfortunatelly this is impossible. The VBScript
object is part of the VBScript engine created to
execute your page. After completing the page it is
destroyed by default. IIS supports some script engine
caching, but you have no enough control over it.
Thus this will not help.

What you can do?

Many alternatives but you will need to cross the ASP
boundaries. Write a COM object is obvious - WSC can be
used if you want to do this in script. But you will need
to play a little with its registry settings may be. You
can try to do something with my ScriptManager component,
but you will need to take care about some things manually.
However this could be a good idea - depend on how much work
can be saved going that way.

Here is the link http://www.newobjects.com/prodct/ID/63

What you can do - load a script into your own script engine
Set host = Server.CreateObject("The_Script_ManagerID ...")
host.LoadEngine "VBScript"
host.AddText somescript
' probably loaded from a file
host.Run
Then all the methods implemented in the loaded script
are available through:
host.script.method_name
This means the entire script acts like a class but the
script engine life time depends on your decision - not on
the IIS decision. And you can save this engine to the session
Set Session("x") = host
then call
Session("x").script.a_method_from_the_script

Well there are some details about this - script engine
supports both and free-threaded models - you can choose what
is appropriate when choosing which ID to use in CreateObject, but
the script itself (the script property) will not synchronize
correctly if called concourently from many pages. There are some
components in the same DLL that may help, but in any case you will
need to do some tests in order to find the best way.

With WSC this will be more simple but less dynamic - you cannot
specify at run-time the script source for example and so on.

Well see if it worths to try some of these things - if your work
will benefit of a good solution in this direction ok but if this
is and will be an exception I suggest you to see if you
can implement the class in an include file and use the session
as its state storage - e.g. initialize/save the state of the object
 in it.

Michael





-----Original Message-----
From: Andy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 14, 2002 7:54 AM
To: ActiveServerPages
Subject: problem with object in session


I have an object variable, which is an instance of an ASP class, that I am
trying to store in a session:

<%
class myClass

function myMethod
  ..do some stuff
end function

end class
%>

I do this:

set obj = new myClass

set session("x") = obj

and then later this:

set myobj = session("x")
myobj.myMethod

but when I try to call myMethod on myobj I get this error:

"Object doesn't support this property or method: 'myMethod'"

I am able to call myMethod on the object before I put it in the session,
so I know it's there and working. For some reason, pulling it out of the
session seems to cause this crazy behavior. Does anyone have a clue as to
what might be happening here?

Thanks.

---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%


---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to