views:

906

answers:

3

Following up from my last question does anyone know how I can use a dictionary object in application scope in Classic ASP? You cannot use Scripting.Dictionary - if you try you will see something similar to the following:

Application object error 'ASP 0197 : 80004005'
Disallowed object use /xxx.asp, line 2. Cannot add object with apartment model behavior to the application intrinsic object.

I found this article on (good ol') 4GuysFromRolla but it points to Microsoft's free Lookup Component and a free Dictionary Component from Caprock Consulting - both of which are dead links.

The article clearly explains why you can't use the Scripting.Dictionary in application scope, but I was wondering if anyone knew of a free alternative or where I might find a copy of the old components that 4GuysFromRolla mentioned?

A: 

I was able to download the Dictionary Component from Caprock Consulting using this link: http://web.archive.org/web/20000619122506/http://www.caprockconsulting.com/data/CaprockDCT.zip

JustinStolle
A: 

I have the LookupTable-component and can provide it to you if interested.

However, I have notived that you can use .NET HashTable in application-scope which might be useful for you.

just do this:

<object id="YOUR_VAR_NAME" progid="System.Collections.HashTable" runat="Server" scope="Application"></object>

this will give you a global, application-wide HashTable-object.

Beware of modifying this to heavily though, I have problems with memoryleaks where eventually the applications session-handling gets unreliable (doesn't invoke SessionStart properly)

jishi
+1  A: 

i had the same issue and ended up feeding the application variable with the content of my dictionary and added

 for each obj in application.Contents
  if Left(obj,6) = "urlLog" then
   application.Contents.Remove(obj)
  end if
 next

to kill all the application variables in the global.asa on application.end ( you could also use the Application.Contents.RemoveAll but i heard there was som issue with it leaving some variable up and causing memory leak even tho i could net find any solid source to prove it ...

anyway is the Caprock dictionary working for you ?

Lil'Monkey