My file, located at 'C:/Users/Username/Desktop/sample.pdf' is there. I can open it manually and it loads fine. Now if I put an invalid link, such as, file:///sample.pdf, which clearly can't be found, the Hololens app will open the Edge browser attempting to open the pdf. So, it's clear the code is functioning.
So why then is this uri incorrect when loading in the Hololens at run-time?
string uriToLaunch = "file:///C:/Users/Username/Desktop/sample.pdf";
// Create a Uri object from a URI string
var uri = new Uri(uriToLaunch);
Task task = new Task(
async () =>
{
// Launch the URI
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
});
task.Start();
task.Wait();
Here is the exception thrown.
Exception thrown: 'System.ArgumentException' in Assembly-CSharp.dll
WinRT information:
The provided URI scheme can't be launched.
Unhandled 'Platform.InvalidArgumentException' exception caught! - 'The parameter is incorrect.'
The parameter is incorrect.
The provided URI scheme can't be launched.', Sender: 'null'. Missing try/catch blocks.
The tricky thing with these exceptions in the Hololens is sometimes they don't seem to be related to whats not working. I've tried googling the error and nothing helpful appears.
EDIT: string uriToLaunch = #"file:///Data/myFiles/sample.pdf";
returns WinRT information: The provided URI scheme can't be launched.
The parameter is incorrect.
string uriToLaunch = #"/Data/myFiles/sample.pdf";
returns UriFormatException: Invalid URI: The format of the URI could not be determined.
NOTE I thought I could open the Edge browser from the app but I'm having trouble replicating this functionality. The only thing that responds, positively, shall we say, is
#"ms-appx:///Data/myFiles/sample.pdf";
This opens up a separate dialog box that will take my to the MS store to try and buy an app that will open ms-appx files.
EDIT 2:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
Task task = new Task(
async () =>
{
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
Debug.Log("Picked photo: " + file.Name);
}
else
{
Debug.Log("Cancelled");
}
});
task.Start();
task.Wait();
I've tried implementing this simple FileOpenPicker, just to test and see if I could get one working, to no success.
It throws this:
Exception thrown: 'System.Exception' in mscorlib.ni.dll
Unhandled 'Platform.COMException' exception caught! - 'Invalid window handle.
EDIT 3: This is all I can find on the error.
COMException
If the ErrorCode property of the exception has the value 0x80070578 (ERROR_INVALID_WINDOW_HANDLE), this indicates that the method was not called on the UI thread.
EDIT 4: Now it's crashing and returning:
Exception thrown: 'System.Exception' in mscorlib.ni.dll
The program '[4084] hololensapplication.exe' has exited with code -1073741189 (0xc000027b).
As #AVK points out, UWP apps are sandboxed. This means files outside of the Hololens local environment aren't reachable. There are local known folders on the HoloLens, but the only way to get around this is to use third party apps such as OneDrive, Azure, etc.
Related
In my UWP app I have the following code:
private async void testButton_Click(object sender, RoutedEventArgs e)
{
var picker = new Windows.Storage.Pickers.FolderPicker();
StorageFolder folder = await picker.PickSingleFolderAsync();
}
but when I run this it fails on the second line with the message An exception of type 'System.Runtime.InteropServices.COMException' occurred in .... but was not handled in user code. The HRESULT from the exception is -2147467259 = 0x80004005 = E_FAIL.
I'm using file pickers already elsewhere in the app without problem. This is running on a Win10 desktop (launched from VS2015). Can anyone suggest why the error occurs and/or what to do to resolve it? Having a meaningless error message in what appears to be the simplest code possible I'm not sure how to proceed.
This is a bit of an oddity in WinRT. Although it is not mentioned in the documentation explicitly, it is necessary to add at least one item in the FileTypeFilter collection:
var folderPicker = new FolderPicker();
folderPicker.FileTypeFilter.Add("*");
await folderPicker.PickSingleFolderAsync();
You can use a specific extension like ".jpg", but it doesn't seem to have effect in a FolderPicker anyway. The only thing that matters is that at least one valid item is present.
When attempting to download asset files for Minecraft, half of the files fail with a download error : "An exception occurred during a WebClient request."
With the InnerException being : "{"The process cannot access the file 'C:\\Users\\[redacted]\\AppData\\Roaming\\[redacted]\\Minecraft 1.10\\assets\\objects\\bdbdf48ef6b5d0d23bbb02e17d04865216179f510a' because it is being used by another process."}".
I am using the FileDownloadCompleted event.
I have also tried adding a "." to the end of each file that doesn't have a proper extension but it has not solved the problem.
Also, this problem is not consistent. Some files with similar names download normally, while other files fail to download. However, it's not an Internet issue either and I have tested on multiple computers.
How can I resolve this exception?
As a makeshift workaround, I have added a while loop to wait for the file to become available.
else if(e.Error.InnerException is IOException)
{
bool canAccess = false;
while (!canAccess)
{
try
{
File.Move(Userstate[0], Userstate[0]);
canAccess = true;
Debug.Print("Can now access file: " + Userstate[0]);
}
catch(IOException) { }
}
}
This code is part of the DownloadCallback handler, and checks the status of e.Error.InnerException. This does not seem like the best solution, but it's the only one I have come up with.
I'm trying to throw together a simple app that uses pedometer data on a Windows 10 phone. I normally live down in kernel-land, and this is my first time using most of the c# async stuff, so I'm wondering if I'm missing a core concept here.
My first attempt at getting data out was to simply report the number of recorded steps over the last hour to a textbox in my XAML app. I just created a basic XAML app, dropped a text box in, and added this event handler:
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
var history = await Pedometer.GetSystemHistoryAsync(DateTimeOffset.Now.AddHours(-1), TimeSpan.FromHours(1));
int count = history.Sum(entry => entry.CumulativeSteps);
textSteps.Text = count.ToString();
}
A breakpoint on the first line triggers, but before it hits the next line I get an unhandled exception. Error code -2147467259, message "Error HRESULT E_FAIL has been returned from a call to a COM component."
The top frame of the stack is in my code, but it's just the boilerplate line from App.g.i.cs that triggers a break on an unhandled exception. Below that is mscorlib and the WinRT invoker.
I looked through the app capabilities list in the manifest, and didn't find anything that looked like it applied to the pedometer. I'm testing this on a Lumia 950.
UPDATE: I just tried calling the API to get the default pedometer sensor:
Pedometer p = await Pedometer.GetDefaultAsync();
It turns out that this triggers an access denied exception with the same worthless stack. I'm currently doing more research to see if there is something that needs to be specified in the manifest.
After further experimenting got me an access denied error, I looked into the manifest more. The manifest Microsoft example project for the pedometer declares a device property that I can't find a way to add through the designer view. Adding it to the code worked perfectly. It's saying I've taken 300,000 steps in the last hour, but I'm sure some simple debugging will find the answer there. (The property is called CumulativeSteps, so that's a good hint...)
<Capabilities>
<DeviceCapability Name="activity" />
</Capabilities>
var currentReadings = await Pedometer.GetSystemHistoryAsync(DateTime.Today);
var walklist = new List<PedometerReading>();
var runlist = new List<PedometerReading>();
foreach (var cuurentreading in currentReadings)
{
if (cuurentreading.StepKind == PedometerStepKind.Walking)
{
walklist.Add(cuurentreading);
}
if (cuurentreading.StepKind == PedometerStepKind.Running)
{
runlist.Add(cuurentreading);
}
}
var item = walklist.Last();
var item1 = walklist.First();
var item2 = runlist.Last();
var item3 = runlist.First();
Steps1.Value += (item.CumulativeSteps - item1.CumulativeSteps);
Steps1.Value += (item2.CumulativeSteps - item3.CumulativeSteps);
First: this is code:
url = "ftp://user%40site.com:pass#ipblabla51/somefile.json";
downloadOperation = downloader.CreateDownload(new Uri(url), file);
Progress<DownloadOperation> progress = new Progress<DownloadOperation>(progresschanged);
try
{
await downloadOperation.StartAsync().AsTask(backgroundDownloader.Token, progress);
/// some code
}
When i'm running at x86 file is downloading OK, but when i'm running it on ARM Device, error is thrown:
on this line:
await downloadOperation.StartAsync().AsTask(backgroundDownloader.Token, progress);
with code: HRESULT E_FAIL has been returned from a call to a COM component.
But.. when i change URL to
"https://eu.nicehost.com/files/somefile.....dasda.json";
Code is running well.. so the problem is in URL parsing,
%40 is a # char. When i change it to #, background downloader can't authorize ftp client.
So how to do it?
So.. if someone will have this trouble, he need to change hosting, or change account name, where there will not be any '%40' or other unicode chars.
I just changed a server ant it works well, so maybe thi is bug? who knows..
I'm trying to build an app for android (school project (technology)), however,
I'm keep getting an error and searching on the internet, gave no answer. So I'm hereby asking in here.
I got an MySQL 5.6 Server up and running, it works. PHP standalone and Xampp for file directory, and everything works fine in browser. The error occurs on the the arrow sign and exception error is about access (I think). I can upload the PHP files if needed.
The first one is a button, the second is an event fired when download is complete.
private void LoginButton_Click(object sender, EventArgs e)
{
TextView userName = FindViewById<TextView>(Resource.Id.editTextUsername);
TextView userPass = FindViewById<TextView>(Resource.Id.editTextPassword);
client = new WebClient();
url = new Uri(#"http://127.0.0.1/memento/accountcheck.php");
//url = new Uri(#"http://127.0.0.1/memento/phpinfo.php");
/*
NameValueCollection parameters = new NameValueCollection();
parameters.Add("Username", userName.Text);
parameters.Add("Password", userPass.Text);
*/
client.DownloadDataCompleted += Client_DownloadDataCompleted;
client.DownloadDataAsync(url);
}
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
Console.WriteLine(e.Result); // <------
}
EDIT:
Unhandled Exception: System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid. Check InnerException for exception details.
Exception Settings: C++ Exceptions, Common Language Runtime Exceptions, JavaScript Runtime Exceptions, Managed Debugging Assistants & Win32 Exceptions.
Each contain tons of check checkboxes except JavaScript. It contains one "0x80070005 Access is denied".