Windows Phone 8.1 File Picker UnauthorizedAccessException - windows-phone

I have a problem trying to replicate the File Picker example in link, I create a new application using a Universal Application Windows store template.
I extract the content of the class Scenario02 and create a similar one in my example. This class implements an interface called IFileOpenPickerContinuable which I extract from the class ContinuationManager and create a file in my project with the same name to implement that interface.
I don't get any compilation errors when I run the application. When the line openPicker.PickMultipleFilesAndContinue(); is executed, it throw a exception.
'UnauthorizedAccessException'(Access is denied. Exception from HRESULT: 0x80070005) exception.
In the Microsoft example they don't modify any of the manifests of the application. Do you know what can I be missing?

(Question solved in a question edit. Converted to a community wiki answer.)
The OP wrote:
Solved! The problem was trying to launch the data picker in the class constructor.

Related

XamlParseException when using UserControl from class library dll

I have created a library which has a Popup UserControl similar to the one here.
When I create a fresh Universal Windows App and create the same UserControl inside an app and open the popup, it opens.
But if I create a Class Library and create the same UserControl inside it and try to use it (by opening the popup) inside an app, I get a XamlParseException.
It is as follows -
Windows.UI.Xaml.Markup.XamlParseException occurred
HResult=-2144665590
Message=XAML parsing failed.
Source=Windows
StackTrace:
at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation
componentResourceLocation)
at PopupTestLibrary.MyUserControl1.InitializeComponent()
I am not able to understand exactly why this is happening, since the code works fine when not called from an external class library.
Some Questions I found to be similar to mine, here on SO -
XamlParseException when consuming a Page from a library
Cannot instantiate UserControl from another assembly
All help is appreciated!
You need to Add a Resource Dictionary in your App and Add the Usercontrol Xaml content to it
as Xaml is Considered as a Content file not compiled into the code
I think that this post is just as yours.. :
https://social.msdn.microsoft.com/Forums/en-US/63f071be-a3c5-4f2d-ace2-73ca750e3252/rtm-usercontrol-class-library-and-assembly-name-with-
And, It's known issue:
Dot in the project's name cause XAMLParseException
I hope that this will help you in your issue..

navigating to a page class in a library in WP8

I have created a page class in the windows phone class library and I referenced that dll in windows phone app project(WP8).
Now how do i navigate to the page class created in the library..How do i specify the uri?
The exact API and syntax would help please.
I have tried using the this.frame.Navigate(typeof(pagename)) as well as the NavigationService.Navigate(new uri("/pagename.xaml",UriKind.relative))..Both of the above are not working..I am assuming there is a mistake in the path specified in the uri..
The following did work for me correctly.
NavigationService.Navigate(new Uri("/AssemblyName;component/MyPage.xaml", UriKind.Relative));
or to generalize the Uri , its format should be : /{assemblyName};component/{pathToResource}
Just be sure you don't have dot"." in your assembly name as it may result in some uri format exception.
Hope this works.

navigationservice.navigate not available on the vs2013 project

I have two page application and the main page is default is "MainPage.xaml" and the second one is "AddPerson.xaml" when user click a button on main page I want the app to take user to "AddPerson" page.
And I wrote following for the Click event of the button
Me.Frame.Navigate(System.Type.GetType("AddPerson.xaml"))
and I am getting the following error
An exception of type 'System.NullReferenceException' occurred in MedicineSchedule.exe but was not handled in user code
Additional information: Object reference not set to an instance of an object.
If there is a handler for this exception, the program may be safely continued.
I tried other method of navigationservice.navigate which I cannot find the class in VS2013 express at all. The only method available is Me.Frame.Navigate in my project, please let me know how I can get this simple thing to work.
If it was .net 2.0 I would simple called new form with form.lod or something similar.
This doesn't work?
this.Frame.Navigate(typeof(AddPerson));
If you want/have to use a string take a look at the reply here:
convert string to type of page

Using ResourceDictionary from a DLL in Windows 8

How can I use the ResourceDictionary resource from the same DLL?
Basically I am trying to create a UI library with all classes derived from Page class. I want to keep all user interface pages in the same DLL.
To see the problem, from VS2012, create a Windows 8 library project, then add the Item Detailed Page. Now, if you open the created page from the editor, you will get some errors like "The resource "LayoutRootStyle" could not be resolved".
This is just a Xaml Designer error, so that will not prevent your project from building or running .
The only thing needed is that all the ResourceDictonary need to be referenced by the main application App.xaml (for example by using <ResourceDictionary Source="/<myLibraryName>/Common/StandardStyles.xaml"/> or by creating calling an Init method in the Library which will dynamically add the Resource dictionary).
A quick workaround for the error in the Xaml Designer is to just copy an App.xaml/App.xaml.cs in your library (but at runtime the main application will still need to have a reference on the needed ResourceDictionary since the App.xaml of the library will not be used).
Another posibility is to just add a refrence on the ResourceDictionary on each page but I believe that will be much more costly since it will create an instance of the dictionary for each page.

"The tag 'MenuItem' does not exist in XML namespace 'clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit'" error

I'm getting an error trying to build a Silverlight application on a new machine. (Silverlight 4, Visual Studio 2010) This application compiles without error on four other machines.
The error is:
the tag 'MenuItem' does not exist in XML namespace 'clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit'.
The references appear to be pointer to the correct assemblies. Has anyone else ever had this problem?
Another reason this issue may occur is due to missing a reference to all "three" assemblies required to use the portions of the the Toolkit controls.
Make sure you have reference to the following assemblies if attempting to use the Toolkit inputs (and assuming the themes also possibly).
System.Windows.Controls
System.Windows.Controls.Toolkit
System.Windows.Controls.Input.Toolkit
This solved the problem I was having in relation to the error.
http://marktinderholt.wordpress.com/2011/07/12/silverlight-toolkit-for-silverlight-5-beta
its the recompiled toolkit in SL5, just reference those and you're set
You can always fall back on creating the context menu in code.
public LedgerEntryControl()
{
InitializeComponent();
ContextMenu contextMenu = new ContextMenu();
MenuItem voidMenuItem = new MenuItem() { Header = "Void" };
voidMenuItem.SetBinding(MenuItem.CommandProperty, new Binding("Void"));
contextMenu.Items.Add(voidMenuItem);
ContextMenuService.SetContextMenu(this, contextMenu);
}
looks like you're missing the Silverlight Toolkit on that machine, but it's installed on the four other ones.
For some reason, the SilverLight Toolkit from NuGet Package Manager is for SL4, even when the project is set to SL5. You can download the SL5 version directly from CodePlex. Note that the date is December 2011, instead of February 2011 like the SL4 version.
If for some reason the MSI does not install (which happened to me), you can extract the files contained in the MSI using 7-zip. All I had to do was manually add a reference to System.Windows.Controls.Input.Toolkit.dll from the extracted files, and my SL5 project now compiles successfully with its NumericUpDown control. Happily, my program now compiles both in Release and Debug mode.
Also to add, for those who have not already done so, you may need to have a reference in the XAML to the correct toolkit. I used the following:
<sdk:Page xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" ... >
Note that the first part, where is says input, is what needs to be typed in the XAML to use the control:
<input:NumericUpDown x:Name="myControl" ... />