ref new WriteableBitmap(1, 1) - The application called an interface that was marshalled for a different thread. RRS feed

  • Question

  • Create a new Metro Direct3D project. Go to the main function (or Run, Load, etc) and add:

    		using namespace Windows::UI::Xaml::Media::Imaging;
    		auto bitmap = ref new WriteableBitmap(100, 100);
    	catch (Platform::COMException^ e)
    		auto message = e->Message;

    The message is "The application called an interface that was marshalled for a different thread." Why can't I create a WriteableBitmap? It works fine in a blank metro project. Also, why are exceptions so poorly handled by Visual Studio? Without a try catch block, all that happens is a message printed to the debug output:

    First-chance exception at 0x771A56C4 in Jumbline2Win.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x038BED44.

    with no exception helper to view the details. A new editor window with "No Source Available" with a useless call stack:

    myApp.exe!myApp::[Windows::ApplicationModel::Core::IFrameworkView]::__abi_Windows_ApplicationModel_Core_IFrameworkView____abi_Run() twinapi.dll!Windows::ApplicationModel::Core::CoreApplicationView::Run() Line 808 twinapi.dll!`Windows::ApplicationModel::Core::CoreApplicationViewAgileContainer::RuntimeClassInitialize'::`55'::<lambda_C91BC4E451DFC06D>::operator()(void * pv) Line 476 twinapi.dll!`Windows::ApplicationModel::Core::CoreApplicationViewAgileContainer::RuntimeClassInitialize'::`55'::<lambda_C91BC4E451DFC06D>::<helper_func>(void * pv) Line 526 SHCore.dll!_PathIsNetworkPathW@4() kernel32.dll!@BaseThreadInitThunk@12() ntdll.dll!___RtlUserThreadStart@8() ntdll.dll!__RtlUserThreadStart@8()

    • Edited by brentAtBrainium Tuesday, April 17, 2012 9:38 PM Clean up call stack
    Tuesday, April 17, 2012 9:36 PM


All replies