2016-11-02 10 views
1

既存のWebサイトをRebus 0.45からRebus 2.0にアップグレードしようとしていて、System.Web.ThreadContext.AssociateWithCurrentThreadがnull参照でクラッシュする問題が発生しました。なぜ私は絶対に考えていないので、私が探している可能性のある原因を探しています。.NET非同期コアのRebusクラッシュ

私が持っている唯一のトレースが登録Windowsのイベントログでメッセージを送信しようとするときは、次の

An unhandled exception occurred and the process was terminated. 

Application ID: /LM/W3SVC/1/ROOT/website 

Process ID: 14460 

Exception: System.NullReferenceException 

Message: Object reference not set to an instance of an object. 

StackTrace: at System.Web.ThreadContext.AssociateWithCurrentThread(Boolean setImpersonationContext) 
    at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext) 
    at System.Web.LegacyAspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) 
    at System.Web.LegacyAspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state) 
    at System.Web.LegacyAspNetSynchronizationContext.Post(SendOrPostCallback callback, Object state) 
    at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.PostAction(Object state) 
    at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task& currentTask) 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Threading.Tasks.AwaitTaskContinuation.<>c.<ThrowAsyncIfNecessary>b__18_0(Object s) 
    at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) 
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() 
    at System.Threading.ThreadPoolWorkQueue.Dispatch() 
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() 

ウェブサイトは城ウィンザー依存性注入でASP.NET MVC 3.0を実行しているとREBUSを使用していますonewayクライアントとしてのトランスポートセットアップ用のSQLServer:

var busConfigurer = Configure.With(new CastleWindsorContainerAdapter(container)) 
    .Logging(l => l.Use(new RebusLoggerFactory())) 
    .Routing(t => t.TypeBased().AddEndpointMappingsFromAppConfig()) 
    .Subscriptions(s => s.StoreInSqlServer(dbConnectionString, "RebusSubscriptions_v2")) 
    .Transport(t => t.UseSqlServerAsOneWayClient(dbConnectionString, "RebusMessages_v2")) 
    Start(); 

".NET 4.5"アプリケーションプール用にIISがセットアップされています。

ウェブサイトを開始し、バスのログ:

- Sending SubmissionCreatedEvent -> SelfService.Service.input 

...とブームを:ログに記録し、メッセージがREBUSを経由して送信され、後で

- Supplied connection string will be modified to enable MARS 
- Database already contains a table named 'RebusMessages_v2' - will not create anything 
- Supplied connection string will be modified to enable MARS 
- Starting periodic task 'CleanupTrackedErrors' with interval 00:01:00 
- Starting bus 1 
- Started 

!アプリケーション全体がクラッシュします。

メッセージを送信する前に、アプリケーションはNHibernateと対話して操作に関する詳細を格納しています。

更新

Bus.Send(msg).Start()Bus.Send(msg)を変更することにより、私は同期と同じエラーをトリガおよびVisual Studioでデバッグするとき、次のスタックトレースを取得することができます。

Exception thrown: 'System.NullReferenceException' in System.Web.dll 
Exception thrown: 'System.NullReferenceException' in mscorlib.dll 
System.Transactions Critical: 0 : 
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>/LM/W3SVC/1/ROOT/website-2-131225642632547395</AppDomain> 
<Exception><ExceptionType>System.NullReferenceException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Object reference not set to an instance of an object.</Message><StackTrace> at System.Web.ThreadContext.AssociateWithCurrentThread(Boolean setImpersonationContext) 
    at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext) 
    at System.Web.LegacyAspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) 
    at System.Web.LegacyAspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state) 
    at System.Web.LegacyAspNetSynchronizationContext.Post(SendOrPostCallback callback, Object state) 
    at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.PostAction(Object state) 
    at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task&amp;amp; currentTask) 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Threading.Tasks.AwaitTaskContinuation.&amp;lt;&amp;gt;c.&amp;lt;ThrowAsyncIfNecessary&amp;gt;b__18_0(Object s) 
    at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) 
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() 
    at System.Threading.ThreadPoolWorkQueue.Dispatch() 
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()</StackTrace><ExceptionString>System.NullReferenceException: Object reference not set to an instance of an object. 
    at System.Web.ThreadContext.AssociateWithCurrentThread(Boolean setImpersonationContext) 
    at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext) 
    at System.Web.LegacyAspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) 
    at System.Web.LegacyAspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state) 
    at System.Web.LegacyAspNetSynchronizationContext.Post(SendOrPostCallback callback, Object state) 
    at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.PostAction(Object state) 
    at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task&amp;amp; currentTask) 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Threading.Tasks.AwaitTaskContinuation.&amp;lt;&amp;gt;c.&amp;lt;ThrowAsyncIfNecessary&amp;gt;b__18_0(Object s) 
    at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) 
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() 
    at System.Threading.ThreadPoolWorkQueue.Dispatch() 
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()</ExceptionString></Exception></TraceRecord> 

更新II

Bus.Publish(msg)bus.Advanced.Routing.Send("SelfService.Service.input", msg)に置き換えてください。だから明らかにサブスクリプション/ルーティングのものに何か間違っているので、Send(...)はそれをバイパスします。どうやらweb.configファイルで<httpRuntime targetFramework="4.6" ...を追加

更新III

は(今のところ、それはまだ少し不安定なようです)問題を解決しました。 web.configファイルが既に<compilation ... targetFramework="4.6">を持っていた:

<system.web> 
    <httpRuntime targetFramework="4.6" maxRequestLength="5000" requestValidationMode="2.0" /> 
    <compilation debug="true" targetFramework="4.6"> 
     <assemblies>...</assemblies> 
    </compilation> 
    <pages validateRequest="false"> 
     <namespaces>...</namespaces> 
    </pages> 
    </system.web> 
+0

私は "nullreferenceexception onthreadenterprivate"のためのグーグルで私は[この他のSOのポスト](http://stackoverflow.com/questions/12969071/async-logging-throwing-a-nullreferenceexception)には、非同期のものを「待って」いるのを忘れてしまいます。それは、あなたが 'バスを待っているのを忘れてしまったので簡単なことができますか? – mookid8000

+0

"await"オペレータは非同期メソッド内でしか使用できません。既存のコードはどれもasyncではありません。この非同期のものはすべて私には新しくなので、どんな助けも高く評価されています:-) –

+0

関連項目Update III –

答えて

1

修正は、ウェブサイトは、.NET 4.5以降を実行していることを確認することが判明:

<system.web> 
    <httpRuntime targetFramework="4.6" /> 
    <compilation targetFramework="4.6"> 
    ... 
    </compilation> 
</system.web> 

どうやらASP.NETチームはASPを作りました。 .NETでより多くのタスクを認識する.NET。

関連する問題