
Passing VB OLE objects in the Application object (IIS3, VB5, ASP, VBS)
VB5 creates COM servers that support the apartment threading model.
You typically would not want to create apartment-threaded objects with
application or session scope unless you are willing to live with the
severe performance hit that results.
See the ASP roadmap for more details on this.
Quote:
>If anyone can offer an explaination for this, I would appreciate it.
>I have created an in-process ActiveX Dll (marked for unattended execution)
>in VB5. I can create an instance of the object in an ASP page just fine.
>However, I want to create the instance in the global.asa
>Application_OnStart event, and pass the object from page to page in the
>Application object, like this:
> Sub Application_OnStart
> Set MyObj = Server.CreateObject("foo.bar")
> Set Application("foobar") = MyObj
> End Sub
>---------
>Then, in an ASP page, I could do this:
> Set MyLocalObj = Application("foobar")
> MyLocalObj.SomeProperty = 1
> MyLocalObj.SomeMethod
>This works in MS Commerce Server with the commerce server objects. I am
>doing a commerce application, so I am leveraging the model.
>However, unlike commerce server, I did not write my objects in C++. I
>wrote them in VB5.
>What I am trying to do does not work. I get no errors in the global.asa.
>In fact, I can verify that the object is correctly created and works just
>fine in the global.asa. The reference, however, does not survive through
>the Application object assignment. I get an error message on the "Set
>MyLocalObj = Application("foobar")" line above, stating that an object is
>required. That is the error message that the 'Set' statement gives when
>the right hand side is not an object reference.
>I can move the object creation to the page level, but that defeats the
>purpose (due to my design, which I am beginning to regret).
>Does anyone know of a way that I can work around this problem, and allow
>the VB object reference to be correctly assigned into and out of the
>Application object?
>--- Nick Malik
> VB MVP
actual e-mail hostname is cais.com. If you reply by email
then change the destination hostname to the above.