ppltasks.hの_ContextCallbackに、理解できない最初のチャンスの例外があります。
私のプロジェクトは、WinRTとネイティブの混合アプリケーションです。アプリケーションは複数のサブプロジェクトで構成されており、そのうちの1つはWinRTを使用しています。WinRTコードは、メインスレッドとは別のスレッドで実行されている静的ライブラリにあります(これを変更することはできません)。WinRTコードは、Visual Studio2012RCで生成されたDirect3Dメトロアプリからコピーされます。
コードは、単純なシェーダーの1つをロードしようとします。
void CubeRenderer::CreateDeviceResources()
{
Direct3DBase::CreateDeviceResources();
// going to crash while attempting to load a file.
auto loadVSTask = DX::ReadDataAsync("SimpleVertexShader.cso");
ファイルは正しい場所に存在し、機能することが証明されています。
ここでコードがクラッシュします。_M_context._M_pContextCallbackが無効です。
void _Reset()
{
if (_M_context._M_captureMethod != _S_captureDeferred && _M_context._M_pContextCallback != nullptr)
{
_M_context._M_pContextCallback->Release();
}
}
出力ウィンドウに次の情報が表示されます。MyApplication.exeの0x00E34C89での初回例外:0xC0000005:アクセス違反の読み取り場所0xCDCDCDCD。
スタックトレースは次のようになります。
MyApplication.exe!Concurrency :: details :: _ ContextCallback :: _ Reset()Line 620 C ++ MyApplication.exe!Concurrency :: details :: _ ContextCallback :: operator =(const Concurrency :: details :: _ ContextCallback&_Src)Line 563 C ++ MyApplication .exe!Concurrency :: task_continuation_context :: operator =(const Concurrency :: task_continuation_context&__ that)C ++ MyApplication.exe!Concurrency :: task :: _ ContinuousTaskHandle、std :: integer_constant、Concurrency :: details :: _ TypeSelectorAsyncOperation> :: _ ContinuousTaskHandle、 std :: integer_constant、Concurrency :: details :: _ TypeSelectorAsyncOperation>(const std :: shared_ptr>&_ AncestorImpl、const std :: shared_ptr>&ContinuationImpl、const DX :: ReadDataAsync ::_l3 ::&_ Func、const Concurrency :: task_continuation_context&_Context、Concurrency :: details :: _ TaskInliningMode _InliningMode)3292行目C ++ MyApplication.exe!Concurrency :: task :: ThenImpl>(const DX :: ReadDataAsync :: _l3 ::& _Func、Concurrency :: details :: _ CancellationTokenState * _PTokenState、const Concurrency :: task_continuation_context&_ContinuationContext、bool _Aggregating、Concurrency :: details :: _ TaskInliningMode InliningMode )Line 3584 C ++ MyApplication.exe!Concurrency :: task :: then <>(const DX :: ReadDataAsync :: _l3 ::&_ Func)行2882 C ++ MyApplication.exe!DX :: ReadDataAsync(Platform :: String ^ filename)行42 C ++ MyApplication.exe!CubeRenderer :: [Direct3DBase] :: CreateDeviceResources()行30 C ++
したがって、_ContextCallbackに問題があり、そこで行き詰まります。
- このコンテキストコールバックとは何ですか?タスクから別のタスクに移ることと関係があるようです。
- それが無効である場合、それはどのように起こったのでしょうか?
- 単に正しく設定されていない場合、どうすれば正しく設定できますか?
動作させることはできますが、WinRTを使用するようにアプリケーション内のすべてのサブプロジェクトを変更する必要があります。残念ながら、これらの他のサブプロジェクトのコードも私の制御の及ばないため、これは許容できる解決策とは見なされません。また、ここで実際に何が起こっているのかを理解したいと思います。
洞察やアイデアはありますか?ありがとう!