Windows phone 8.1 app crashing while using libphonenumber-csharp - windows-phone-8

I am trying to use libphonenumber-csharp library for my windows phone project for validating international phone numbers. I have installed the library using the following command on nuget package manager console:
Install-Package libphonenumber-csharp
I am using the following click event handler to test the functionality of the library:
private void buttonCall_Click(object sender, RoutedEventArgs e)
{
String bdNumberStr = "0123456789";
PhoneNumbers.PhoneNumberUtil phoneUtil = PhoneNumbers.PhoneNumberUtil.GetInstance();
try
{
PhoneNumbers.PhoneNumber numberProto = phoneUtil.Parse(bdNumberStr, "BD");
}
catch (PhoneNumbers.NumberParseException exc)
{
Debug.WriteLine("NumberParseException was thrown: " + exc.Message);
}
}
The program is crashing after clicking the button. The event handler function is not getting hit and an exception is thrown. In output window it says something like the following:-
Loaded 'C:\Data\Programs{60688B3F-2E3D-46EE-B0DE-C1F3E22F0912}\Install\PhoneNumbers.DLL'. Cannot find or open the PDB file.
Does anyone have an idea whats going wrong here?

You can't use this package, this library built for desktops, not for Windows Phone or Store apps.
You need to port it by yourself or find another solution.

Related

Monotouch crashes with no exceptions

I built a monotouch app it randomly crashes after user fnishes signup the problem is that no exception is being thrown, I tried to catch that with the debugger while testing it on a device (of course I set it up to catch all exceptions) I even tried to set up crash tool such as HockeyApp but those crashes don't appear any where.
How can I solve this? help please!
You should check out Raygun.io. It will log any unhandled exceptions to the dashboard. Add it via a nuget package and then you can set it up with one line in your Main.cs:
namespace Myapp.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
Mindscape.Raygun4Net.RaygunClient.Attach("enter your api key here");
UIApplication.Main(args, null, "AppDelegate");
}
}
}

Parse with Windows Phone 8 Universal Apps

I have a Windows 8.1 Universal app that I am using with Parse. I have downloaded the latest .NET libraries for Parse and included the Parse.dll and ParseWindows.dll in the Windows 8 project. The app works just fine with them.
I then include the Parse.dll and parsePhone.dll in the Windows Phone app. When the phone app runs, I get a FileNotFound exception when the ParseClient.initialize method is called. The method is in a static class within my Shared library, and is used by both projects. It works fine in the Windows 8 app, but throws the exception in the Windows Phone app.
This is the method that gets called, with the keys redacted.
public static class ParseCloudService
{
public static void InitializeParseCloudService()
{
try
{
ParseClient.Initialize("AppIdGoesHere", ".NETKey");
}
catch(ParseException)
{
throw;
}
}
}
Has anyone else ran in to this? Is there something that I'm supposed to be adding to the Windows Phone 8.1 app that the Parse library expects? Again, this is in a Universal app, and not a standard Windows Phone app project (previous posts I've made this gets confused).
Another interesting thing, is that even though I have this wrapped in a try/catch, the exception goes thrown within the Intialize() method, and never gets caught by my try/catch. If I set a break-point in my catch, the breakpoint never gets hit. It throws within Initialize(), then immediately breaks within app.g.i.cs file.
Could not load file or assembly 'System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
and this is the stack trace:
at Parse.PlatformHooks.SettingsWrapper..ctor()
at Parse.PlatformHooks.SettingsWrapper.get_Wrapper()
at Parse.PlatformHooks.get_ApplicationSettings()
at Parse.ParseClient.get_ApplicationSettings()
at Parse.ParseClient.get_InstallationId()
at Parse.ParseClient.Initialize(String applicationId, String dotnetKey)
at Actions.Services.ParseCloud.ParseCloudService.InitializeParseCloudService()
at Actions.Services.ParseCloud.ParseCloudUserService..ctor()
at lambda_method(Closure , IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
Thanks in advance!
The Parse .NET SDK will not be updated to support Windows Phone 8.1.
Source: https://developers.facebook.com/bugs/327073484113608/

stackoverflow exception on calling asmx service from scheduletaskagent in wp8

I have a wp8 project that references a wp8 class library. The class library has a service reference. I also have a wp8 task agent project that references the class library to update the live tiles. When calling the service methods from the phone project everything works great but when I call a service method from the task agent I start getting a stack overflow exception or out of memory exception.
protected override void OnInvoke(ScheduledTask task)
{
string userName = GetUserName(); //from isolated storage
MyServiceClient client = new MyServiceClient ();
client.GetDataCompleted += client_GetData;
client.GetDataAsync(username);
}
The error occurs on GetDataAsync. However when I use the same code in the phone app(not the task agent) everything is working fine.
Has anyone noticed something similar?
Thanks,
Kunal

Using the Box Windows (.NET) V2 API in Web C# project

Is it possible to use the following SDK for a Web Application:
https://github.com/box/box-windows-sdk-v2
The specs say it is targeted for the .NET framework for Windows and Windows Phone applications, but I wasn't able to figure it out for a Web .NET project. Is this SDK strictly for native Windows and Windows phones applications?
I've never used await/async functions in C# and that's possibly where I can't figure it out. I've been able to successfully get an oauth2 token/refresh token, but don't know where to go from here. Could anyone take a look or provide a sample of how to retrieve folder details?
Thanks !
It is absolutely possible to use the Box Windows SDK in an ASP.NET web application.
I've recently updated the readme documentation to mention that the SDK supports the .NET 4.0 framework, so as long as your project is targeting that framework or above you should be good to go. If you are running an express version of Visual Studio, you unfortunately will not be able to open the SDK source project as it's built as a PCL (Portable Class Library). You can, however, still get the binaries through nuget.
One important thing you have to remember when using async/await calls in ASP.NET is that you have to include the Async="true" attribute in your Page declaration:
<%# Page Language="C#" Async="true" %>
You mentioned that you were able to successfully get OAuth2 tokens/refresh tokens. I'm not sure if you wrote your own workflow to retrieve those tokens, but the SDK supports handling the second step of exchanging an auth code for tokens as follows:
public async Task Authenticate(string authCode)
{
BoxConfig config = new BoxConfig("YOUR_CLIENT_KEY", "YOUR_CLIENT_SECRET", new Uri("YOUR_REDIRECT"));
BoxClient client = new BoxClient(config);
await client.Auth.AuthenticateAsync("authCode");
}
Note that when using async/await, you must decorate your method signature with the "async" keyword. Microsoft has written great articles on further understanding the async/await keywords.
In the case that you built your own OAuth2 workflow, the SDK also accepts a completed OAuth Session. Here's a full sample of that, and an example of getting items in your root level folder:
public partial class WebForm1 : System.Web.UI.Page
{
BoxClient _client;
protected async void Page_Load(object sender, EventArgs e)
{
BoxConfig config = new BoxConfig("YOUR_CLIENT_KEY", "YOUR_CLIENT_SECRET", new Uri("https://YOUR_REDIRECT"));
BoxClient client = new BoxClient(config);
OAuthSession session = new OAuthSession("YOUR_ACCESS_TOKEN", "YOUR_REFRESH_TOKEN", 3600, "bearer");
_client = new BoxClient(config, session);
}
protected async void Button_Click(object sender, EventArgs e)
{
BoxFolder folder = await _client.FoldersManager.GetItemsAsync("0", 10);
string test = folder.Name;
}
}

How to solve "Native methods are not allowed in loaded code" error

I want to let my app to run sound while the playbook in standby mode, I put this statement in the start up
QNXSystem.system.inactivePowerMode = QNXSystemPowerMode.THROTTLED;
Now when I debug the app on the simulator (not desktop debugger) I got this error
VerifyError: Error #1079: Native methods are not allowed in loaded code.
And this error I got also when using AlertDialog.
Note: I am using Flash builder, and I have put the qnx SWC in the libraries path.
.... so to solve these problems?
To allow code compiled w/native extensions to run on the simulator, we had to put code that used native extensions in methods that would never get executed (when on the simulator).
It wasn't enough to just wrap the offending code in an if/else block. The if/else needs to call another method that either has the native version or the simulator version of the code.
For example:
private function showNativeOrFlexAlert(message:String):void
{
// we used the Capabilities class to determine this, might be a better way
if (isMobile)
showNativeAlert(message);
else
showFlexAlert(message);
}
// have to be careful here, this method signature CANNOT include
// any classes from native extension -- no errors on device, but fails on simulator
private function showNativeAlert(message:String):void
{
// use native API to show alert
}
private function showFlexAlert(message:String):void
{
// use the Flex Alert class
}
Set the qnx-air.swc linkage to "external".