CurrentAppSimulator.RequestProductPurchaseAsync Win 8.1 doesn't work? - c#

Calling the new
var result = await CurrentAppSimulator.RequestProductPurchaseAsync("id");
doesn't work in Windows 8.1?
But when I call await CurrentAppSimulator.RequestProductPurchaseAsync("id", false); it does work though this method is depreciated and I need the result for consumable In-Apps.
Also by "doesn't work" I mean nothing happens. It doesn't bring up the testing popup windows for "CurrentAppSimulator" and just fails.

My test product ID was just not set right... silly me.

Couple of suggestions: Run the app once calling any method on CurrentAppSimulator. Close your app and look at the WindowsStoreProxy.XML file that the simulator creates in your app folder C:\Users\\AppData\Local\Packages\\LocalState\Microsoft\Windows Store\ApiData\WindowsStoreProxy.xml.
This file is created in UTF-16 format. If you take this file and edit it you will have better luck than if you try to create your own file.
http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.store.currentappsimulator has more details.
Last tip is to remember that this file is never written to. you have to edit it to setup each scenario.
And you'll also have better luck if you create and deploy your own copy for testing.
For me, the file would load but no functions worked when I had it save just a plain ascii file or even after changing it to UTF-8. Had to be saved as UTF-16 to work end-to-end. It would have been nice if the simulator had given some feedback on the ReloadAsync call to save me hours of pain and frustration.

Related

Xamarin Forms PCLStorage files are lost after app stops debugging

Using PCLStorage in Xamarin Forms I can create a local folder and store images downloaded from Azure.
I can then successfully test to see of the images exists using
ExistenceCheckResult fileExist = await MyFolder.CheckExistsAsync(fileName);
However, once the app has been stopped (by stopping debugging in Visual Studio) and restarted, if I run the test code above, it fails and tells me the images do not exist.
Do files then only exist for the time the app is running?
This thread looks like it could possibly cover what you are experiencing:
https://forums.xamarin.com/discussion/87498/i-am-using-pclstorage-where-are-the-files-going-to
Reading up on this, the file persistence side of things looks like debugging should not affect it, as once it writes the file - then it's in the specified location.
Also - looking at PCLStorage and the last time it was modified, if this is a new addition to your project, I can't say I would recommend it, as it looks like it is no longer being worked on, and hasn't been for some time.
I would go with an implementation from System.IO as it is now supported within .net standard 2.0 - and there appear to be lots of great examples for you to follow.
If this doesn't help, then post some more of your source code so that it can be looked into in further detail.

Starting an executable with a custom configuration file

I am working on a simple C# project that calls for me to launch a program, pointing it at a custom configuration file. Specifically, I'm launching DOSBox with a custom config file that tells it what to do upon starting. I've used shortcuts before, and essentially this is what I put in the shortcut and it works perfectly.
"D:\Video Game Emulation\DOSBox\DOSBox.exe" "D:\Video Game Emulation\DOS Windows\GAMES\CUSTOM.CONF"
Now the program I'm writing is just a prettier way of launching a bunch of old DOS games through DOSBox, each with their own custom config. So in my button code, here's what I have.
Process.Start("D:\\Video Game Emulation\\DOSBox\\DOSBox.exe", "D:\\Video Game Emulation\\DOS Windows\\GAMES\\CUSTOM.CONF");
According to my understanding that is the proper way to start an executable and give it a custom option. However, that launches just fine, but doesn't pass in the config file properly. I also tried this.
Process.Start("D:\\Video Game Emulation\\DOSBox\\DOSBox.exe", -conf "D:\\Video Game Emulation\\DOS Windows\\GAMES\\CUSTOM.CONF");
With no luck either. Anyone know what I need to change in order for it to give DOSBox the custom configuration file properly?
Pass in the path as a string, so put your quotation marks in and test it.
Basically the reason is when checking Intellisense (spelling?), it shows an overload for Start(string fileName, string arguments).
So it wouldn't hurt to make sure you are passing strings into both.
Edit: I think I may have seen it before you edited your post. Did you have the quotation marks in the code?
OK, sorry it has taken so long to get back to this thread, but I've been quite busy. Thanks to help from dakre18, StarPilot, and Bearcat9428 I figured it out. It seems that the working directory has to be specified in the StartInfo in order for it to work. Things seem to work now. Thanks for all your help everyone!

What's the default file path in WinRT/WP 8.1?

Hello fellow programmers.
I recently made a mistake while using the SQLite-NET package for Windows Phone 8.1. When opening a new SQLiteConnection, I would give as parameter to its constructor the string "data.db", without being actually aware of what was going on under the hood. Later on, I noticed that the file wouldn't be deleted, even if I uninstalled the application (since I would have in my app the same entries that I had before uninstalling it); I assume that I should be using the local folder for application data instead.
However, here is the real question: what the hell is the folder where the data.db file was created? I tried to figure it out with the following piece of code:
var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///data.db"));
System.Diagnostics.Debug.WriteLine(file.Path);
and what I got as output of the WriteLine method was the path
C:\Data\SharedData\PhoneTools\AppxLayouts\f7529f24-ba24-4fdb-8353-cff9214180a0VS.Debug_ARM.Valbrand\data.db,
which only got me even more confused. I couldn't find any satisfactory info on this, and I would REALLY like to further my understanding of what happened here.
Thanks in advance!
The path you are looking at is the install directory of your app. You have a Silverlight 8.1 app, so the path is slightly different than a Silverlight 8.0 app, but the articles here and here will help you get a rough understanding.
The recommended usage of this directory is to take the resources that you want backed up out of it on first run and move them to the app data container, so they can be backed up by the system.
C:\Data\SharedData\PhoneTools\AppxLayouts\f7529f24-ba24-4fdb-8353-cff9214180a0VS.Debug_ARM.Valbrand\data.db
This is the path on your phone/emulator.
And This is not the location where you can find in your PC.

windows phone 8, applicationsettings not persisted

I have the following strange behaviour in my Windows phone 8, C# App.
I am saving a Setting with:
private void SaveProperty<T>(T property, string propertyName)
{
if (IsolatedStorageSettings.ApplicationSettings.Contains(propertyName))
IsolatedStorageSettings.ApplicationSettings[propertyName] = property;
else
IsolatedStorageSettings.ApplicationSettings.Add(propertyName, property);
IsolatedStorageSettings.ApplicationSettings.Save();
}
When the app runs, I can read all settings I stored in IsolatedStorageSettings.ApplicationSettings.
But when I re-open my app (open it from the app list), the IsolatedStorageSettings.ApplicationSettings-Dictionary contains Zero (0) Keys and Values.
Am I missing something?
I used the ISETool.exe to take snapshots of the IsolatedStorage of my app (thanks to chepene).
I saw this behaviour: when I wrote the Settings (that means after the SaveProperty<T>() function finished), and the app is still running, I have the Settings saved in _ApplicationSettings. This agrees with my Observation that I can read from the IsolatedStorageSettings.ApplicationSettings when the app is running.
The _ApplicationSettings-file also exists when the is tombstoned or not running (when I can Access it by Holding the back-button of the phone and when the app is closed with the back-button).
But when the app is opened again (via the app list), the _ApplicationSettings-file is gone...
I also see that, when I'm writing a file into the IsolatedStorage with:
SharedStorageAccessManager.CopySharedFileAsync(
Windows.Storage.ApplicationData.Current.LocalFolder, fileName+"orig",
Windows.Storage.NameCollisionOption.ReplaceExisting, fileID);
and when I then don't read this file, it is gone when I open the app the next time.
By the way, to avoid confusion: I am not reinstalling the app each time I open it.
If you need more Information please ask.
Any help appreciated.
With AppSettings, I've seen something similar on WP7/7.5, but it happened only when my property-value's type was a class that was not known to the serializer.
Are you sure that there were no exceptions:
during Save
during App Exit (since the App may dump the settings at that point)
during the time that App loads the settings for the first time after launch?
Note that this doesn't necessarily must mean the app crashing. I mean, any exceptions, those internally silenced or user-handled too. Please check the VisualStudio's Output panel for "first chance exceptions" log. If any I/O or security or serialization exception shows up, then investigate there. If i remember well, there's even a whole set of isolated-storage exceptions that are easily interceptable from debug/exceptions menu.
However, the issues I had with unknown or nonserializable types does not explain at all why your extra non-appsettings files would evaporate.
Another thought: maybe some additional tool performs something like 'clean deploy' for you? I don't remember exactly, but I think that VisualStudio's deployment cycle was quite plain:
rebuild
remove/uninstall old app from device -- so probably purges isolatedstorage
install new app onto device
So, maybe that's the cause? Hm.. on afterthought and re-reading your question again, you've said about running the app from the applist, so that rather is not the case. Be sure to check firstchance exceptions then!
Thanks to quetzalcoatl I found the solution:
I am storing all my files in the root Folder of my app. At the start I am then reading all my files (via a DataContractSerializer) and casting it to my model. Since it happens sometimes that my files get corrupt, I delete every file which throws a SerialzationException. But as I read every file, and since _ApplicationSettings is not castable to my model, I am deleting _ApplicationSettings automatically.... So I learned that the ApplicationSettings are,just a file in the root folder, which I am allowed to read and delete. So the quintessence is to never write into the root Folder.

Reading a Bitmap from a TIF file - Works in WinForms not in ASP.NET

EDIT Solution Found: See my post below.
We are writing a library that reads in a TIF file from a scanner. Basically, its a scantron. We are examining the form and reading values from it.
Currently we have a windows test app, and we give it a filepath as a string ("c:\testing\image.tif"). It loads up the tif, reads the document correctly and parses the values.
We also have an ASP.NET web application. We have a test page that does exactly what the windows app does, we hand it an identical string, and i calls the same function on the same class from the same library. It however does NOT read the form correctly. We have verified that it does it fact load up the tif file, and it is actually filled with data (pixels we expect to be white/black are white/black when we examine the Bitmap obect in the immediate window of Visual Studio).
The specific problem is in a library called DataMatrix we use to scan a bar-code off the document. This function is supposed to return a List<string>, each of which is a barcode the library found on the document. In the windows app, this function (DataMatrixDecoder.DecodeBarcode(bitmap)) correctly returns with a Count=1. When using the asp.net app, this returns with Count=0.
Because its the exact same image file, I cannot imagine the problem is in DataMatrix. I can only assume its something with ASP.NET or something.
This isn't even my project, but another guy and I are helping our coworker figure this out, and we are just pulling our hair out. All signs indicate that ASP.NET is correctly loading and handing the image off disk to the "processor" class (which is a class library that uses the DataMatrix stuff, we are not doing ANY code in ASP.NET except for opening/handing the file to the function.).
Does anyone have any ideas as to what it might be, or different things we can check?
I'm not even sure what kind of information to give so I tried to say it all, if you have any questions please ask I'd be more than happy to elaborate on anything. Thanks.
edit:
this is the code on the ascx.cs code-behind, in a button-click event:
if (formReader.ReadTIFF(#"c:\testing\image.tif"))
{
messages.Controls.Add(HtmlHelper.DivSuccess("Read successful."));
}
The formReader class then open the file with a FileStream, and uses that to create a Bitmap. The ASP.NET application is not actually opening the file at all (we were uploading it through a FormUpload control, but after experiencing problems we dummied it down to this). This is the most perplexing thing, that it works in the windows app but not from this web site. ASP.NET has full permissions on that folder to do whatever it wants. It can open the image fine, and the bitmap it creates from the FileStream is the actual image.
edit: Also, the ReadTIFF function right now copies the FileStream into a MemoryStream, ensuring its a not a problem streaming from disk (the entire file is in memory).
How are you passing the filepath to the web application?
It is possible that the function which Decodes might be swallowing some exception.
Use reflector to examine the library (if you have not written it).
I agree. It seems your problem is most probably related to User rights on the directory where you're trying to access the files from. Try giving your Web users the Full access rights on the source directory.
EDIT
Solution Found: The problem was that the open file dialog was changing the CurrentWorkingDirectory. The reason the website never worked, was because the Environment.CurrentDirectory was set incorrectly. When I manually set the CurrentDirectory to the websites' bin folder, parsing works correctly.
Small update. Using the Windows App, and selecting the file via OpenFileDialog, will cause the barcode decoder to fail. Technically, I am using the exact same string to hand to the parser ("c:\testing\image.tif"), yet when I use the OpenFileDialog to get the string, the decoder fails. Is there a clue in this?
update: In fact, even if I don't use the string the OpenFileDialog gives me, if I just open the file dialog at all, it will fail. I don't get this. It's something simple. I need to debug the C++ DataMatrix library, really.

Categories