2011-06-28 10 views
8

いくつかの静的フィールドの内容が一見無作為に失われているASP.NETアプリケーションをデバッグしています。私はいくつかの簡単なカスタムロギングをしました(log4netは不安定だったので)、アプリケーションが2つのアプリドメインにロードされていることがわかりました。ログからの抜粋です:複数のアプリケーションドメインまたは頻繁なアプリケーションのリサイクルで1つのASP.NETアプリケーション(偶然)

6/27/2011 9:01:01 PM /LM/W3SVC/1/ROOT/MyApp-1-129537072581658334: log message 1 
6/27/2011 9:01:01 PM /LM/W3SVC/1/ROOT/MyApp-1-129537072581658334: log message 2 
6/27/2011 9:01:01 PM /LM/W3SVC/1/ROOT/MyApp-1-129537072581658334: log message 3 
6/27/2011 9:01:01 PM /LM/W3SVC/1/ROOT/MyApp-1-129537072581658334: log message 4 
6/27/2011 9:01:02 PM /LM/W3SVC/1/ROOT/MyApp-4-129537072620628334: log message 5 <- 
6/27/2011 9:01:02 PM /LM/W3SVC/1/ROOT/MyApp-4-129537072620628334: log message 6 
6/27/2011 9:04:50 PM /LM/W3SVC/1/ROOT/MyApp-1-129537074647228334: log message 7 
6/27/2011 9:04:50 PM /LM/W3SVC/1/ROOT/MyApp-1-129537074647228334: log message 8 

時刻/日付の後の項目が現在のアプリケーションドメイン名です。

アプリケーションは、AJAXリクエストを処理してASP.NETライブラリの束に渡すだけの、通常のASP.NET(MVCではない)アプリケーションです。唯一の珍しいことは、ライブラリの1つが少しのリフレクションを使用していくつかのクラスを検索し、別のスレッドでそれらをインスタンス化して実行することです。しかし、それは明らかにアプリドメインでは何もしません。

ところで、ログファイルの強調表示された行は、ASPXハンドラからのASP.NETアプリケーション自体(つまり、別のスレッドからではありません)からのものです。

ログを正しく解釈していますか?もしそうなら、アプリケーションを複数のアプリケーションドメインからロードして提供する原因は何ですか?

編集:この質問は本質的にはこの1つに関連しています:ASP.NET Application state vs a Static object。しかし、私が今日見たものに基づいて、静的なフィールドに依存することはできないようです。私はすべてをApplicationオブジェクトに移すことができますが、同期はちょっと面倒ですね。私はアプリケーションが何か非標準的なことをしていることをますます確信しています。

編集2:私はもう少し調査しましたが、アプリケーションとアプリケーションドメインの間には常に1対1の関係があるようです(これは私が期待するものです)。だから、私が見ているのはリサイクルだと思う。

編集3:いくつかのより多くの実験の後とチャンスをうかがっ、私は(http://blogs.msdn.com/b/tess/archive/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles.aspxに基づいて)IISヘルスモニタリングを有効にし、アプリケーションを素早く2回連続して起動していることが分かりました。それは非常に困惑しています。ログイベントは次のとおりです。

Event code: 1003 
Event message: Application compilation is starting. 
Event time: 6/28/2011 8:34:31 AM 
Event time (UTC): 6/28/2011 3:34:31 PM 
Event ID: d42336b18c264516a4ba5aa1e62df276 
Event sequence: 1 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT/MyApp-1-129537488697736549 
    Trust level: Full 
    Application Virtual Path: /MyApp 
    Application Path: [snip]\MyApp\ 
    Machine name: US-SEA-R9759B2 

Process information: 
    Process ID: 7624 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\DefaultAppPool 

---- 

Event code: 1001 
Event message: Application is starting. 
Event time: 6/28/2011 8:34:33 AM 
Event time (UTC): 6/28/2011 3:34:33 PM 
Event ID: f7fbecb1ba1a4a24833016cec47458c6 
Event sequence: 1 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT-2-129537488729428362 
    Trust level: Full 
    Application Virtual Path:/
    Application Path: [snip]\RootApp\ 
    Machine name: US-SEA-R9759B2 

Process information: 
    Process ID: 7624 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\DefaultAppPool 

---- 

Event code: 1001 
Event message: Application is starting. 
Event time: 6/28/2011 8:34:40 AM 
Event time (UTC): 6/28/2011 3:34:40 PM 
Event ID: 07a3dc31e8804caca1ddc3b2101962e3 
Event sequence: 1 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT-3-129537488807712839 
    Trust level: Full 
    Application Virtual Path:/
    Application Path: [snip]\RootApp\ 
    Machine name: US-SEA-R9759B2 

Process information: 
    Process ID: 7624 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\DefaultAppPool 

---- 

Event code: 1001 
Event message: Application is starting. 
Event time: 6/28/2011 8:34:40 AM 
Event time (UTC): 6/28/2011 3:34:40 PM 
Event ID: db304b519a084fa797fbcfe66fbb0b48 
Event sequence: 1 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT/MyApp-4-129537488808502885 
    Trust level: Full 
    Application Virtual Path: /MyApp 
    Application Path: [snip]\MyApp\ 
    Machine name: US-SEA-R9759B2 

Process information: 
    Process ID: 7624 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\DefaultAppPool 

MyAppアプリケーションは、別のアプリケーション(RootApp)に存在します。私が期待しているのは、2つのログメッセージ、MyApp起動とRootApp起動です。

答えて

1

あなたのサイトには、web.configファイル、dlls、aspx、asmx、またはその他のファイルを変更しているものがあります。これらのファイルが変更されるたびに、Webアプリケーションの新しいインスタンスが開始され、古い要求が既存のアプリケーションから処理されている間に、新しいWebアプリケーションから新しい要求が処理されます。すべての古い要求が完了すると、古いアプリケーションはシャットダウンされます。これは配備に適しています。既存のセッションを壊すことはありませんが、すべてのリクエストやそのような場合にweb.configファイルを自動的に変更する必要はありません。

このページでは、これが http://technet.microsoft.com/en-us/library/cc759560(WS.10).aspx

2

をどのように機能するかをより良い詳細に説明しますが、誤って2にアプリケーションプールのプロパティ]([パフォーマンス]タブ)でのワーカープロセスの数を設定しましたか?

これらのプロパティでは、番号やリクエスト、またはそれらのリサイクル設定に基づいてAppPoolのリサイクルをあまりにも頻繁に行うような設定もあります。

関連する問題