Using a dictionary object in application scope in Classic ASP

邮差的信 提交于 2019-12-23 12:28:57

问题


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?


回答1:


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




回答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)




回答3:


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 ?



来源:https://stackoverflow.com/questions/909877/using-a-dictionary-object-in-application-scope-in-classic-asp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!