I have app that supports ShareTarget to upload files to cloud. Everything works great when I my app is closed (and I mean closed - not hibernated or something like this) - I choose share photo and everyting goes as expected. But when I open the app, then exit (app stays hibernated in memory) and try to share something on line
Window.Current.Activate();
I get
Exception thrown: 'System.InvalidCastException' in mscorlib.ni.dll
Message "Unable to cast COM object of type 'System.ComponentModel.PropertyChangedEventHandler' to class type 'System.ComponentModel.PropertyChangedEventHandler'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface."
Then my app closes completely and second try is success. Whole onShareTarget code:
protected override void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
{
if (!args.ShareOperation.Data.Contains(
Windows.ApplicationModel.DataTransfer.StandardDataFormats.StorageItems))
return;
AppShell shell = Window.Current.Content as AppShell;
if (shell == null)
shell = new AppShell();
Window.Current.Content = shell;
shell.AppFrame.Navigate(typeof(ChooseFolderPage), args.ShareOperation);
Window.Current.Activate();
}
Any ideas how to fix it?