Reputation: 431
I've been unable to personally reproduce this error on any of my development machines, but it's been reported several users. When trying to initalise a share contract to share files, an exception occours.
StorageFile ExportFile = await model.Export();
if (ExportFile == null) return;
if (DataTransferManager.IsSupported())
{
DataTransferManager.GetForCurrentView().DataRequested +=
(sender, e) => Share_DataRequested(sender, e, ExportFile);
DataTransferManager.ShowShareUI();
}
else
{
ErrorHelper.showError("Your device does not support sharing.");
}
This code calls the function:
private void Share_DataRequested(DataTransferManager sender, DataRequestedEventArgs args, StorageFile file)
{
try
{
args.Request.Data.Properties.Title = file.DisplayName;
args.Request.Data.SetStorageItems(new List<StorageFile>() { file });
}
catch (Exception e)
{
args.Request.FailWithDisplayText("Error occured");
ErrorHelper.showErrorReporter("Export error", e.Message + Environment.NewLine + e.StackTrace, "The export failed.", BugType.Export_Error);
}
}
This fails for some reason when attempting 'SetStorageItems' with the following stack trace:
ComTypeMarshalling_MissingInteropData, System.Collections.Generic.IEnumerable<Windows.Storage.IStorageItem>. For more information, visit http://go.microsoft.com/fwlink/?LinkId=623485
at SharedLibrary!<BaseAddress>+0x43bf7e
at SharedLibrary!<BaseAddress>+0x43c0ba
at SharedLibrary!<BaseAddress>+0x43901c
at Songbook!<BaseAddress>+0x19f791b
at Songbook.Models.Exporters.ExportMaster.Share_DataRequested(ApplicationModel.DataTransfer.DataTransferManager sender, ApplicationModel.DataTransfer.DataRequestedEventArgs args, Storage.StorageFile file)
I've been unable to a solution to this anywhere, anybody got any suggestions?
Upvotes: 1
Views: 154
Reputation: 4298
I know I'm late to the party, but maybe it still helps... The problem occurs on release builds (using .NET native toolchain compiler), when referencing the Microsoft.NETCore.UniversalWindowsPlatform
NuGet package in version 5.3 or newer. It seems there is some type mismatch / casting problem going on under the hood. Try to explicitly setting the type passed to the SetStorageItems
method:
IEnumerable<IStorageItem> files = new IStorageItem[] {file};
args.Request.Data.SetStorageItems(files);
If this still does not help, a quick fix (although not very future-proof) might be to just downgrade the Microsoft.NETCore.UniversalWindowsPlatform
reference to 5.2.4.
Upvotes: 1