4

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?

Community
  • 1
  • 1
joshcomley
  • 28,099
  • 24
  • 107
  • 147

3 Answers3

3

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
  • 4,182
  • 3
  • 37
  • 48
2

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
  • 24,126
  • 6
  • 49
  • 75
  • 2
    Actually, it's possible to create a scripting.dictionary in the application-scope aswell: add that to your global.asa – jishi Jan 25 '11 at 17:18
  • +1 Just what I needed. Thank you. Is there some drawback with using the Dictionary as a global object as with the HashTable? – Ricardo Souza May 29 '14 at 14:40
  • @rcdmk I think I saw the same memory leak tendencies with the Dictionary as well, so I would advise against modifying the dictionary heavily. – jishi May 30 '14 at 08:59
  • Ok, thanks. I just use it to create a global dict and populate it on global.asa with some texts I use to localize the site. – Ricardo Souza May 30 '14 at 12:54
1

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
  • 991
  • 6
  • 14