我有ppltasks.h的_ContextCallback中的第一次機會異常,我只是不明白。ppltasks中的第一次機會異常_ContextCallback類
我的項目是一個混合WinRT /本機應用程序。該應用程序由多個子項目組成,其中一個使用WinRT。 WinRT代碼位於與主線程不同的線程中運行的靜態庫中(並且我沒有權力改變它)。 WinRT代碼是從Visual Studio 2012 RC中生成的Direct3D metro應用程序複製的。
代碼試圖加載簡單的着色器之一:
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();
}
}
輸出窗口給出:0000005:在0x00E34C89在MyApplication.exe 第一次機會異常訪問衝突讀取位置0xCDCDCDCD。
堆棧跟蹤的樣子:!
MyApplication.exe併發::細節:: _ ContextCallback :: _復位()線620 C++ MyApplication.exe併發::細節:: _ ContextCallback ::運算符= (常量併發::詳細信息:: _ ContextCallback & _Src)線563 C++ MyApplication.exe!併發:: task_continuation_context ::運算符=(const的併發:: task_continuation_context & __that)C++ MyApplication.exe!併發::任務:: _ ContinuationTaskHandle ,的std :: integral_constant,併發::細節:: _ TypeSelectorAsyncOperation> :: _ ContinuationTaskHandle,性病::積分_constant,併發::細節:: _ TypeSelectorAsyncOperation>(常量性病:: shared_ptr的> & _AncestorImpl,常量性病:: shared_ptr的> & ContinuationImpl,常量DX :: ReadDataAsync :: _l3 :: & _Func,常量併發:: task_continuation_context & _Context,Concurrency :: details :: _ TaskInliningMode _InliningMode)Line 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)Line 2882 C++ MyApplication.exe!DX :: ReadDataAsync(Platform :: String^filename)Line 42 C++ MyApplication.exe!CubeRenderer :: [Direct3DBase] :: CreateDeviceResources()第30行C++
因此,有一些錯誤的_ContextCallback,而這也正是我會被卡住。
- 什麼是此上下文回調?這似乎與從任務轉到另一個有關。
- 如果無效,那怎麼會發生?
- 如果它只是沒有正確設置,如何正確設置它?
我可以得到它的工作,但它涉及到更改應用程序中的所有子項目使用WinRT。不幸的是,這不被認爲是可接受的解決方案,因爲其他子項目中的代碼也不受我控制。我也想試着瞭解這裏發生了什麼。
任何見解或想法?謝謝!
當你說「添加引用」時,你的意思是#include嗎? –