[thelist] ASP: Threading and apartment model

Marcus Andersson marcan at home.se
Thu Jan 8 06:00:58 CST 2004


Hi

I'm in the middle of writing an application for ASP3.0. I want to create
a DAO layer (and some other "managing" classes) inside the web
application and put them in Application scope since the host of the
application don't want to install new COM components. The classes are
written in Jscript. 

The problem is that when I try to instantiate the classes in global.asa
I get "Cannot add object with apartment model behavior to the
application intrinsic object.". I've read that I cannot add objects with
apartment model to the Application object. So how do I create objects of
my Jscript classes that aren't of the apartment model and put them in
the Application object? I don't want to put them in Session or Request
(wich actually do work...) scope since I think that will create a large
overhead in creating/maintaining that amount of objects. The classes
are, by the way, written in a thread-safe way.

I want to do it this way since I'm building a prototype with an
XML-based data storage that is supposed to have a database storage later
on and if I build a DAO layer the only thing that needs to change is
that particular layer when the transition needs to happen. 

The load on the application will not be large (it will actually be very
small) but I still want to do it the way I think is the correct one...

If anyone has other suggestions on how to accomplish the same goals I'd
be more than happy to here about it :)

/Marcus

Part of global.asa:
<!-- global.asa start -->
<!-- The various classes are defined inside these js files -->
<SCRIPT LANGUAGE="JScript" RUNAT="Server"
SRC="serverjs/common.js"></SCRIPT>
<SCRIPT LANGUAGE="JScript" RUNAT="Server"
SRC="serverjs/filehandler.js"></SCRIPT>
<SCRIPT LANGUAGE="JScript" RUNAT="Server"
SRC="serverjs/manager.js"></SCRIPT>
<SCRIPT LANGUAGE="JScript" RUNAT="Server"
SRC="serverjs/person.js"></SCRIPT>
<SCRIPT LANGUAGE="JScript" RUNAT="Server"
SRC="serverjs/user.js"></SCRIPT>
<SCRIPT LANGUAGE="JScript" RUNAT="Server"
SRC="serverjs/security.js"></SCRIPT>
<!-- More managers follows... -->

<SCRIPT LANGUAGE="JScript" RUNAT="Server">
  function Application_OnStart() {
    Application("Util") = new Util();
    Application("FileHandler") = new FileHandler();

    var dataPath = "d:\\bristav.se\\xmldata\\";
    Application("PersonManager") = new PersonManager(dataPath +
"persons.xml");
    Application("UserManager") = new UserManager(dataPath +
"users.xml");
    ... More managers
  }
...



More information about the thelist mailing list