Windows 8.1 FileOpenPicker - windows-8

I made the app for windows store. It worked fine until I upgraded my os to Windows 8.1. There is an error while I'm trying to FileOpenPicker:
Element not found. (Исключение из HRESULT: 0x80070490)
Here is stacktrace:
at Windows.Storage.Pickers.FileOpenPicker.PickSingleFileAsync()
at Crypto.Engine.d__13.MoveNext()
and code:
FileOpenPicker fop = new FileOpenPicker();
fop.FileTypeFilter.Add(".jpg");//extension);
fop.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
try
{
StorageFile file = await fop.PickSingleFileAsync();
return file;
}
catch(Exception ex) {}
How can I fix it?

I encountered the same problem and solved by putting code in the right thread:
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
CoreDispatcherPriority::High,
ref new DispatchedHandler([]()
{
// **ATTANTION**: direct call `PickSingleFileAsync` in render loop will crash
//http://sertacozercan.com/2013/10/fixing-element-not-found-exception-from-hresult-0x80070490-error-in-windows-8-x/
FileOpenPicker^ openPicker = ref new FileOpenPicker();
openPicker->ViewMode = PickerViewMode::Thumbnail;
openPicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
openPicker->FileTypeFilter->Append(".png");
openPicker->FileTypeFilter->Append(".jpg");
openPicker->FileTypeFilter->Append(".jpeg");
auto task = openPicker->PickSingleFileAsync();
}

Related

MS Teams Adaptive cards giving error after integrating it with the code as attachment

I'm trying to integrate this Adaptive Card sample in my Asp.net core code but somehow it is not working and Bot is throwing an error "Bad Request". If i'm using simple text card then it is working fine Sample card only text. I would request you to help me or highlight the issue which is causing the below problem.
Error Details:
Below is my code to attach a card.
private async Task BotUserCallback(ITurnContext turnContext, CancellationToken cancellationToken)
{
var cardAttachment = CreateAdaptiveCardAttachment(_card);
//turnContext.Activity.Attachments = new List<Attachment>() { cardAttachment };
await turnContext.SendActivityAsync(MessageFactory.Attachment(cardAttachment), cancellationToken);
}
private static Attachment CreateAdaptiveCardAttachment(string filePath)
{
var adaptiveCardJson = System.IO.File.ReadAllText(filePath);
var adaptiveCardAttachment = new Attachment()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(adaptiveCardJson),
};
return adaptiveCardAttachment;
}
Finally after debugging and deleting each and every line i got to know that it was because of the wrong Image URL. I have removed the image URL and it worked for me.

Jreport JasperRunManager.runReportToPdfStream null pointer exception

i'm trying to get a PDF report using Jasper in my Java web application but i'm facing to an null pointer exception and i'm not able to find which is the error.
here below my code :
private void caricaReport() {
try{
InputStream is = getClass().getResourceAsStream("reports/miooperearte.jasper");
File OutDir = new File(outputDir);
File outDir = new File(outputDir);
outDir.mkdirs();
OutputStream os = new FileOutputStream(new File(outDir, "testReportNadia.pdf"));
HashMap parameterMap = new HashMap();
parameterMap.put("immagini_base_dir", "/Applications/MAMP/htdocs/Dboperearte/app/webroot/images/");
Collection data = leggiOpere();
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(data,false);
JasperRunManager.runReportToPdfStream(is, os, parameterMap, dataSource);
}
catch (Exception e) {
e.printStackTrace();
}
}
variables "is", "os", "parameterMap" and "dataSource" are all filled, exception doesn't show which is the null problem only say null pointer exception...
any idea which can help me to solve or find the problem ?
Thanks
I would guess that the parameterMap doesn't contain an entry for something that the JasperRunManager is expecting - make sure you aren't missing any values from there.

Sharepoint 2010 overwriting file upload with Client Object Model does'nt work

I am trying to upload a file to the document library using Client Object Model
using MO_NET = Microsoft.SharePoint.Client;
try
{
using (MO_NET.ClientContext ctx = new MO_NET.ClientContext("http://server1-sp2010/sitios/LbkPruebasCurso/"))
{
MO_NET.List lBibliotecaDocumentos = ctx.Web.Lists.GetByTitle("Documentos compartidos");
MO_NET.FileCreationInformation fciArchivo = new MO_NET.FileCreationInformation();
fciArchivo.Content = File.ReadAllBytes(#"..\..\Archivos\RegionInfo.csv");
//se define el nombre del documento en la biblioteca
fciArchivo.Overwrite = true;
fciArchivo.Url = "RegionInfo.csv";
MO_NET.File fToUpload = lBibliotecaDocumentos.RootFolder.Files.Add(fciArchivo);
ctx.ExecuteQuery();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
this code works but it seems to me that the
"fciArchivo.Overwrite = true"
doesn't work. when i try to upload another file with the same name i get an exception.
if i delete the file first teh code works
Can i solve that without deleting previously the file in the library
Thanks a lot

httpwebrequest in windows phone 8 app throws "The remote server returned an error: NotFound."?

i am developing an windows phone 8 app , in my app i am calling services and downloading some data into my app.
i am testing my app in windows phone 8 emulator, many times it throws this error :
"The remote server returned an error: NotFound."
This is how i have created and used my httpwebrequest :-
public async Task<string> ServiceRequest(string serviceurl, string request, string methodname)
{
string response = "";
try
{
var httpwebrequest = WebRequest.Create(new Uri(serviceurl)) as HttpWebRequest;
httpwebrequest.Method = "POST";
httpwebrequest.Headers["SOAPAction"] = "http://tempuri.org/" + iTestservice + "/" + methodname + "";
httpwebrequest.ContentType = "text/xml";
byte[] data = Encoding.UTF8.GetBytes(request);
using (var requestStream = await Task<Stream>.Factory.FromAsync(httpwebrequest.BeginGetRequestStream, httpwebrequest.EndGetRequestStream, null))
{
await requestStream.WriteAsync(data, 0, data.Length);
}
var httpTask = httpRequest(httpwebrequest);
var completeTask = await Task.WhenAny(httpTask, TaskEx.Delay(300000));
if (completeTask == httpTask)
return await httpTask;
else
httpwebrequest.Abort();
throw new TimeoutException("Service Timed Out");
}
catch (TimeoutException Tex)
{
throw Tex;
}
catch (Exception ex)
{
throw ex;
}
}
public async Task<string> httpRequest(HttpWebRequest request)
{
string received;
using (var response = (HttpWebResponse)(await Task<WebResponse>.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null)))
{
using (var responseStream = response.GetResponseStream())
{
using (var sr = new StreamReader(responseStream))
{
received = await sr.ReadToEndAsync();
}
}
}
return received;
}
i am really not able to figure what was the issue
Please note :-
i tried to open the site (service URL which my app is trying to access) in my emulator browser , it opened correctly , i wasn't facing any issues.
1)is that the problem with my code, if so i request you please correct me ??
2)is this any emulator issue or any connectivity issue ??
3)is this any certification issue opening in emulator ??
Even after a long research to how to fix the issue i was not able to fix it .
Please Help me out.
Thanks in Advance.
I have come across this issue when the webservice requests take longer than 60 seconds. I have read reports that the emulator does not throw this error, but only an actual device. In my experience however, I have had this happen on both emulator and device. This is a default timeout setting that cannot be altered, even if you change it in the config. This issue has been around since WP7.
I've only found this question asked/blogged about once elsewhere. Seems that not a lot of people have picked this up.
AFAIK, Microsoft are aware of this, but don't plan on fixing it. (Proven by the fact that it has been around since WP7, and wasn't fixed for WP8). My guess is that they are of the opinion that web calls shouldn't be taking longer than 60 seconds in any case.
I just resolved it adding empty credentials to https requests, like this
httpwebrequest.Credentials = new NetworkCredential("", "");
here he explains why
http://blog.toetapz.com/2010/11/15/windows-phone-7-and-making-https-rest-api-calls-with-basic-authentication/

Windows Azure UploadFromStream No Longer Works After Porting to MVC4 - Pointers?

Updated my MVC3/.Net 4.5/Azure solution to MVC4.
My code for uploading an image to blob storage appears to fail each time in the upgraded MVC4 solution. However, when I run my MVC3 solution works fine. Code that does the uploading, in a DLL, has not changed.
I’ve uploaded the same image file in the MVC3 and MVC4 solution. I’ve inspected in the stream and it appears to be fine. In both instance I am running the code locally on my machine and my connections point to blob storage in cloud.
Any pointers for debugging? Any known issues that I may not be aware of when upgrading to MVC4?
Here is my upload code:
public string AddImage(string pathName, string fileName, Stream image)
{
var client = _storageAccount.CreateCloudBlobClient();
client.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(5));
var container = client.GetContainerReference(AzureStorageNames.ImagesBlobContainerName);
image.Seek(0, SeekOrigin.Begin);
var blob = container.GetBlobReference(Path.Combine(pathName, fileName));
blob.Properties.ContentType = "image/jpeg";
blob.UploadFromStream(image);
return blob.Uri.ToString();
}
I managed to fix it. For some reason reading the stream directly from the HttpPostFileBase wasn't working. Simply copy it into a new memorystream solved it.
My code
public string StoreImage(string album, HttpPostedFileBase image)
{
var blobStorage = storageAccount.CreateCloudBlobClient();
var container = blobStorage.GetContainerReference("containerName");
if (container.CreateIfNotExist())
{
// configure container for public access
var permissions = container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
container.SetPermissions(permissions);
}
string uniqueBlobName = string.Format("{0}{1}", Guid.NewGuid().ToString(), Path.GetExtension(image.FileName)).ToLowerInvariant();
CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName);
blob.Properties.ContentType = image.ContentType;
image.InputStream.Position = 0;
using (var imageStream = new MemoryStream())
{
image.InputStream.CopyTo(imageStream);
imageStream.Position = 0;
blob.UploadFromStream(imageStream);
}
return blob.Uri.ToString();
}