This project is read-only.

RPC_E_WRONG_THREAD Thrown When I Try to Create New WriteableBitmap.

Jun 28, 2013 at 3:45 PM
Hi guys, I'm developing a game using WaveEngine, and I want to share an image through Facebook API, but when I try to create a new WriteableBitmap using the extension method .FromStream() throws the exception:
The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
Here's my snippet:

_wbmp is a WriteableBitmap object...
_wbmp = await new WriteableBitmap(1, 1).FromStream(_fileStream, BitmapPixelFormat.Unknown);
I already tried to use CoreDispatcher but it keeps throwing the same exception.

Anyone of you've face this before?

Thanks in advance.
Jun 28, 2013 at 4:39 PM
Makes sure you create a WriteableBitmap always on the UI thread. For that you should ensure the Dispatcher reference you use is instantiated in the UI thread.
Jun 28, 2013 at 4:55 PM
How can I know if the dispatcher was created in the UI thread?
Apr 15, 2014 at 7:57 PM
I'm having the same problem. How can I call this from a WRC