C# “收到”;System.Runtime.InteropServices.ComeException“;在Windows应用程序中
在我的windows应用程序中,我试图将映像从本地计算机加载到服务器,但在语句C# “收到”;System.Runtime.InteropServices.ComeException“;在Windows应用程序中,c#,windows-phone-7,windows-phone-8,visual-studio-2013,windows-applications,C#,Windows Phone 7,Windows Phone 8,Visual Studio 2013,Windows Applications,在我的windows应用程序中,我试图将映像从本地计算机加载到服务器,但在语句StorageFile=wait open.PickSingleFileAsync()上遇到异常System.Runtime.InteropServices.COMException。方法如下: FileOpenPicker open = new FileOpenPicker(); StorageFile file = await open.PickSingleFileAsync(); if (file != null
StorageFile=wait open.PickSingleFileAsync()上遇到异常System.Runtime.InteropServices.COMException
代码>。方法如下:
FileOpenPicker open = new FileOpenPicker();
StorageFile file = await open.PickSingleFileAsync();
if (file != null)
{
using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
// Set the image source to the selected bitmap
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.DecodePixelWidth = 600; //match the target Image.Width, not shown
await bitmapImage.SetSourceAsync(fileStream);
big_image.Source = bitmapImage;
}
}
如何修复它???我用的是VS'13Big_image
是在xaml
中定义的图像,我正在尝试设置其源。用于拾取图像。用于拾取图像。我通过添加一些新内容获得了解决方案:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
// Set the image source to the selected bitmap
BitmapImage bitmapImage = new BitmapImage();
await bitmapImage.SetSourceAsync(fileStream);
big_image.Source = bitmapImage;
}
}
我通过添加一些新内容得到了解决方案:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
// Set the image source to the selected bitmap
BitmapImage bitmapImage = new BitmapImage();
await bitmapImage.SetSourceAsync(fileStream);
big_image.Source = bitmapImage;
}
}