Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

Scripting.Dictionary in Application

I'd like to create Scripting.Dictionary object in Application_OnStart() in order to get rid of endless calls to database for persistent enough information.
But it fails in accordance with MSDN docs and in fact.
Is there relaible way to create this object for Application?

TIA.
0
OMC2000
Asked:
OMC2000
1 Solution
 
John844Commented:
I would not even try to create this object an application level of scope.  You are begging for trouble if you do.

You might can store the contents of the recordsets in a multidimensional array using rs.getrows().

John
0
 
pjttCommented:
John844 is right. And this especially applies to the dictionary object, which good ol' Microsoft never quite got the threading model right for. That's one way to bring your server to its knees. Storing state information can be a pain sometimes, but there's a huge difference in performance between storing it in the database as opposed to an object in the application or multiple session variables.

Peter Tracey
Developer
http://www.25online.com/peter
0
 
enkay022798Commented:
I disagree with not using Dictionery objects at the application level. We used it vastly in one of my previous projects and never ran into any serious problems.

FOr the threading model to work just go into the registry and set the threading model for the Dictionery object to "Both".

All the best !
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
OMC2000Author Commented:
enkay, the replacement of the "Apartment" with "Both" enables Scripting.Dictionary on Session level, but I still can't create this object on Application level.
What've I missed?
0
 
OMC2000Author Commented:
enkay, the replacement of the "Apartment" with "Both" enables Scripting.Dictionary on Session level, but I still can't create this object on Application level.
What've I missed?
0
 
enkay022798Commented:
>>but I still can't create this object on Application level.

There shouldnt be a problem... where are you creating the object... what happens when it fails ? Do you get an error of any kind ?
0
 
OMC2000Author Commented:
The following code in global.asa:

<SCRIPT LANGUAGE="JavaScript" RUNAT="Server">
...
function Application_OnStart() {
  var c = Server.CreateObject("Scripting.Dictionary");
  Application("eee") = c; // line 92
...
}
...
</SCRIPT>

causes the following error on the first call of any page:

"Application object error 'ASP 0197 : 80004005'

Disallowed object use

/DutchSite/global.asa, line 92

Cannot add object with apartment model behavior to the application intrinsic object.
"
0
 
enkay022798Commented:
Have you rebooted after changing the registry entry ? If the model is Both then why are you getting an error saying it is apartment threaded ?

Microsoft is sometimes strange ... any change to registry should be followed by a reboot.
0
 
OMC2000Author Commented:
Thanks a lot, it really required reboot. I forgot that specific for IIS and other MS Stuff.
0
 
enkay022798Commented:
Glad you got it working :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now