2012-02-19 24 views
1

Classic ASPを使用すると、辞書オブジェクトの配列をアプリケーションオブジェクトに配置することが可能かどうかを知ることができますか?私は試してみましたが、アプリケーションプールの下にあるスクリプトに約50,000回もヒットした後に、この行が実行されたときに、「トラップ可能な」C0000005エラーが生成されます:dictLanguage = Application( "lang")application()オブジェクトに辞書オブジェクトの配列を格納する - Classic ASP

しかし数日。アプリケーションオブジェクトを別の変数に割り当てたやり方と関係がありますが、コピーではなくポインタを渡すと思っていましたか?私より賢い人はここで何が起こっているのか知っていますか?

if isempty(Application("lang")) then 
    ''# called when first visitor hits the page (following server reboot or app pool recycle) 
    init() 
    dictLanguage=Application("lang") 
else 
    ''# called for all other page hits 
    dictLanguage=Application("lang") ''# ***** TRAPPABLE ERROR after a few thousand page views ******* 
end if 


''# // fill the application object with an array containing 10 dictionary objects, each holding a different language. 
''# // This function appears to run just fine. 

function init 

    Set initcn = Server.CreateObject("ADODB.Connection") 
    initcn.Open dbConStr 
    strSQL = "SELECT languageNo,quickRef,text FROM tblTranslation" 
    Set rs = initcn.Execute(strSQL) 

    dim d(10) 

    Set d(1)=Server.CreateObject("Scripting.Dictionary") 
    Set d(2)=Server.CreateObject("Scripting.Dictionary") 
    Set d(3)=Server.CreateObject("Scripting.Dictionary") 
    Set d(4)=Server.CreateObject("Scripting.Dictionary") 
    Set d(5)=Server.CreateObject("Scripting.Dictionary") 
    Set d(6)=Server.CreateObject("Scripting.Dictionary") 
    Set d(7)=Server.CreateObject("Scripting.Dictionary") 
    Set d(8)=Server.CreateObject("Scripting.Dictionary") 
    Set d(9)=Server.CreateObject("Scripting.Dictionary") 
    Set d(10)=Server.CreateObject("Scripting.Dictionary") 

    while not rs.eof 
     a=rs("languageNo") 
     b=rs("quickRef") 
     c=rs("text") 
     ''# on error resume next 
     d(a).Add b,c  
     rs.movenext 
    wend 

    initcn.close 

    ''# Storing the array in the Application object 
    Application.Lock 
    Application("lang") = d 
    Application.Unlock 

end function 
+0

私は大きなものをデータベースやファイルに入れます。 –

+0

既にデータベースに入っています。私は速度のためのアプリケーションオブジェクトのデータをキャッシュしようとしています。すべてのページでデータベースを再クエリすると、パフォーマンスが低下します。 –

+0

それから、 '.GetRows()'を使用します。 –

答えて

2

ディレクティブオブジェクトは、スレッドモデルのためにアプリケーションレベルの変数として使用しないでください。アプリケーションレベルで辞書のようなオブジェクトを使用する必要がある場合は、Microsoftの無料のLookupコンポーネント(またはCaprock Consultingの無料ディクショナリコンポーネント)を使用します。

詳細については、this URLをご覧ください。容易に利用可能であり、アプリケーションオブジェクトに格納されているサポートされてい

+1

ありがとう、そのURLのリンクはすべて死んでいるようですが、それは間違いなく問題の答えです。 –

3

一つの目的は、プログラムID「MSXML2.FreeThreadedDOMDocument.3.0」

を持って使用している場合、これは、かなり静的なアプリケーション全体のデータをロードするにはかなり良い解決策ですSQL ServerとSQL Server FOR XMLを使用すると、DOMにロードするXMLを簡単に作成できるようになります。

関連する問題