Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserializing WriteableBitmap throws exception on WinRT #2

Open
RemcoBlok opened this issue May 23, 2013 · 3 comments
Open

Deserializing WriteableBitmap throws exception on WinRT #2

RemcoBlok opened this issue May 23, 2013 · 3 comments

Comments

@RemcoBlok
Copy link

Hello,

I have an object that has a WriteableBitmap property. When deserializing this on WinRT the following exception is thrown. I'm using await when I invoke LoadAsync. Invoking LoadAsync inside dispatcher.RunAsync does not help. Can you help please?

many thanks,

Remco

   HResult=-2147417842
   Message=The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
   Source=Windows.UI.Xaml
   StackTrace:
        at Windows.UI.Xaml.Media.Imaging.WriteableBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight)
        at Wintellect.Sterling.WinRT.PlatformAdapter.<GetBitmapSerializer>b__5(BinaryReader br) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.WinRT\PlatformAdapter.cs:line 85
        at Wintellect.Sterling.Core.Serialization.ExtendedSerializer.Deserialize(Type type, BinaryReader reader) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\ExtendedSerializer.cs:line 123
        at Wintellect.Sterling.Core.Serialization.AggregateSerializer.<>c__DisplayClass7.<CanSerialize>b__4(BinaryReader reader) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\AggregateSerializer.cs:line 79
        at Wintellect.Sterling.Core.Serialization.AggregateSerializer.Deserialize(Type type, BinaryReader reader) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\AggregateSerializer.cs:line 148
        at Wintellect.Sterling.Core.Serialization.SerializationHelper._Deserialize(BinaryReader br, CycleCache cache) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\SerializationHelper.cs:line 541
        at Wintellect.Sterling.Core.Serialization.SerializationHelper._IteratePropertiesUntilEndOfFileIsReached(BinaryReader br, CycleCache cache, Type typeResolved, Object instance) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\SerializationHelper.cs:line 603
        at Wintellect.Sterling.Core.Serialization.SerializationHelper.Load(Type type, Object key, BinaryReader br, CycleCache cache) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\SerializationHelper.cs:line 473
        at Wintellect.Sterling.Core.Database.BaseDatabaseInstance.<_Load>d__44`1.MoveNext() in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Database\BaseDatabaseInstance.cs:line 774
@RemcoBlok
Copy link
Author

I suspect this is related to the recent commit to set ConfigureAwait(false) to avoid a deadlock. This means that the deserialization does no longer necessarily take place on the ui thread (or more specifically in the original captured context). Calling the WriteableBitmap constructor can only be done on the ui thread apparently. I think some core functionality must be changed to allow deserialization to happen asynchronously using a platform specific dispatcher.

@RemcoBlok
Copy link
Author

my workaround for now is to add SterlingIgnore to the WriteableBitmap property and to add PixelHeight, PixelWidth and PixelBuffer properties. After deserializing I can then create the WriteableBitmap on the ui thread using the PixelHeight, PixelWidth and PixelBuffer properties.

@jplane
Copy link
Contributor

jplane commented May 29, 2013

Sorry for your difficulty... I frankly don't have much time to look into this right now, but when my current project slows down a bit I'll get back to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants