This project is read-only.

hresult: 0x8001010e (rpc_e_wrong_thread) in Navigate


Hi all,
I am working on an Windows 8 App which should act as share target.
For that I implemented the following code apps.xaml.cs:
       protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs args)

            IReadOnlyList<IStorageItem> f = await args.ShareOperation.Data.GetStorageItemsAsync();

            string token = StorageApplicationPermissions.FutureAccessList.Add(f[0]);
            ShareHelper.ShareOperation = args.ShareOperation;
            ShareHelper.FileToken = token;
            NavigationService.Navigate("ShareTarget", null);
This resulted in following exeption

The application called an interface That was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))

at Windows.UI.Xaml.Controls.Frame.Navigate(Type sourcePageType, Object parameter)
at Microsoft.Practices.Prism.StoreApps.FrameFacadeAdapter.Navigate(Type sourcePageType, Object parameter)
at Microsoft.Practices.Prism.StoreApps.FrameNavigationService.Navigate(String pageToken, Object parameter)
at VerifySignatur.App.<OnShareTargetActivated>d__13.MoveNext()

Google did not show useful results.
Does anyone have some glue how to fix that?


GOstrowsky wrote Apr 24, 2014 at 6:58 PM

Hi Josef,

Based on my understanding, the issue remain on trying to navigate on a different thread from the UI Thread. Inside the async method, you would need to call Navigation by invoking the Dispatcher in order to return to the UI Thread.

Replacing the Navigate statement withe the following one should resolve the problem:

Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            NavigationService.Navigate("ShareTarget", null);
I hope this helped,

Gabriel Ostrowsky