stackoverflow exception on calling asmx service from scheduletaskagent in wp8 - windows-phone-8

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

Related

Fake JavaFX Platform start

In my project I have a peculiar setup for testing JavaFX components: First there is an Application that starts the component normally through a main method for visual inspection. But then there are subclasses of this Main classes which are the actual JUnit tests.
In the tests I do not want to run the application with the UI showing up (the tests should also be runnable in a system that has no window manager, e.g. cuntinuous integration). Normally this will throw an error, as the platform is not started. To prevent this, I call:
final Runnable dummyRunnable = new Runnable() {
#Override
public void run() {
System.out.println("Startup platform");
}
};
PlatformImpl.startup(dummyRunnable);
PlatformImpl however is internal API (com.sun.javafx.application.PlatformImpl). Which basically ties the test to a specific brand of JDK.
To figure out if this happens I actually call the method through reflection, so I can log the specific error cases.
Is there a way to reach the same thing (running the tests which are a subclass of Application, but do not call the start method, to run in headless mode)?

NullReference exception on reactivation of app before a call to a MobileFirst adapter returns

I am developing a windows phone 8 silverlight application and I am using
MFP v6.3
The following problem occurs.
If I make a call to a MobileFirst adapter and place the app in the background before that call returns, when I reactivate the app it crashes with this exception.
ExceptionObject {System.NullReferenceException: Object reference not set to an instance of an object.
at IBM.Worklight.WLRequest.responseCallback(IAsyncResult asyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass1d.<InvokeGetResponseCallback>b__1b(Object state2)} System.Exception {System.NullReferenceException}
This happens for any call I have tried.
Does anybody know why this exception is thrown?
Secondly, I would like to know if there is a way to cancel a call. So that I can do it when my app is deactivated.
EDIT: adding adapter call implementation
public void getInvoices(IShowAndProceed showAndProceedVM, JObject parameter)
{
String myContextObject = "MyAppWP8";
WLRequestOptions invoicesOptions = new WLRequestOptions();
invoicesOptions.setInvocationContext(myContextObject);
WLProcedureInvocationData InvoicesInvocationData = new WLProcedureInvocationData("BillingAdapter", "MyInvoicesProcedure");
InvoicesInvocationData.setParameters(new Object[] { parameter });
WLClient.getInstance().invokeProcedure(InvoicesInvocationData, new InvoicesInvokeListener(showAndProceedVM), invoicesOptions);
}
Question #1:
An exception sounds like a defect to me. It will be investigated, but it will help if you will edit the question and add your implementation (for the adapter procedure call).
Edit: Please open a PMR.
Question #2:
It is not possible to 'cancel' a MFP adapter request after it has been executed. You can submit a feature request.

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/

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;
}
}

Enterprise library exception handling problems with WCF services

my application consists of 3 layers and is very straightforward.
class library with all the business logic
WCF service that exposes the class library
asp.net web UI.
At the class library layer, I have an enterprise library exception handling policy defined so that it logs all exceptions to the database. In the underlying code, exceptions are thrown, and they coalesce up to the facade. In the facade, I trigger the EL policy to log the errors, and then I toggle a sucessStatus boolean in the response and have a method to convert all my exceptions to a friendly list so that the ultimate consumer can dig through this to get any idea of whats going on.
My facade in my class library sort of looks like this:
public SomeResponse DoSomething(SomeRequest request)
{
SomeResponse response = new SomeResponse();
try
{
response.data = SomeOperationThatWillThrowAnException;
}
catch (InvalidOperationException ex)
{
var exceptionManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
exceptionManager.HandleException(ex, "StandardPolicy");
response.Errors.Add(Utility.ExceptionToError(ex));
response.SuccessStatus = false;
}
return response;
}
If I build a simple winform client and have it talk to my class library, this works.
However when I use the full stack, I get "fault exception was unhandled by user code". I can't seem to configure EL at the WCF layer in any way to keep this from happening.
My WCF service is just a simple wrapper for my class library facade.
public SomeResponse DoSomething(SomeRequest request)
{
return new MyFacade.DoSomething(request);
}
What I want is to have the class library handle the error silently, and not trigger any exceptions at the WCF or UI level. I want the consumer (in this case the ASP.NET webform UI) to have to check the response message contents to get a clue of what happened instead of having an exception stop execution dead in its tracks.
You likely have an error in your configuration file resulting in GetInstance() or HandleException() throwing an exception. Have you tried debugging the WCF service?