This post pertains to React Native v0.12.0-rc.

I am attempting to port my iOS app in react-native to Android. I am experiencing a bunch of issues surrounding colors and default styles. I am getting TypeError: expected dynamic type ‘string’, but had type ‘int64’.

Attached the debugger to the processes and I am seeing calls to the following code in CatalystStylesDiffMap.class:

Examining the values I see the color property is an int64.

As it turns out the Android project and the node-module for react-native were out of sync and this caused lots of problem with regard to style color properties.

It looks like my application (even when initing a fresh app) was importing java libraries for 0.11 dependencies:

I verified my installed version of react-native

init’ed a new project and looked at the build.gradle file to see it is 0.11+.

Checked the node_modules/react-native/Libraries/StyleSheet to see 0.11 files (0.12+ has a new processColor.js file in it as seen by recent commits.)

So to make this work I changed the build.gradle to 0.12+, and ran npm i react-native@0.12.0-rc to force the correct android libraries and the correct react-native module. Now the app works.

Is this my machine or npm cache that is horked up or is it an npm install problem with the 0.12.0-rc? I also noticed that none of the files in the $PROJECTDIR$/android folder get updated when doing an npm i orĀ npm update which leaves the native app setting behind in version.

Give it a try here: dsandor.github.io

image

It’s no secret that I use BlogEngine.net for my blog.  I have been too busy to rewrite the whole thing but I did have time to test out writing a WebApi to expose my blog data and buid out a tiny AngularJs version of my blog. 

Basically the HTML for the site becomes very small.  Angular provides all the data binding framework.  I even tested out building a jQuery component.

Next, I am going to build out a cleaner version with a more out of the box Bootstrap design and use Backbone for the data binding framework.  I am just working through which I like better so I am using my blog as the test bed.

This is pretty easy.  Basically you can send any property values to the Window object that is being created to hold your root view.  Simply create a Dictionary<string, object> with the property name as the key.  Pass that dictionary to the DisplayRootViewFor<>() method and viola!

I have an application that uses the WPF frame for navigation.  The frame markup looks like this:

This Frame tag is located in my ShellView.xaml file and this takes the place of a ContentPlaceholder.  In order to navigate to another page I simply call ActivateItem( viewModelInstance ) from my ShellViewModel.  Because the ShellViewModel orchestrates the page loads I created a simple ChangeViewMessage class to throw via the EventAggregator.  My ShellViewModel handles this message and passes the viewModel instance to the ActivateItem method.  Caliburn Micro takes care of everything else.

Here is an example of the ShellViewModel loading my initial page/view in the constructor.

You can see that my first view (SelectServersView via the ViewModel) is loaded there.

In order to make Caliburn Micro work you have to patch one method to be ‘Frame Aware’.

In the View.cs class of the Caliburn Micro source in the Caliburn.Micro.WPF project change the SetContentPropertyCore method to look like the one below.  This allows you to use a Frame.

 

 

 

Just posted the code that I am using for an iOS project of mine that handles all the Web Api calls.  

https://github.com/dsandor/WebApiClient/tree/master/src/Monotouch

Example of use:

WebApiClient.Post<ServiceResponse<User>>(string.Format ({0}Auth/Login?emailAddress={1}&password={2}
  , AppDelegate.Current.ApiBase, email.Value, password.Value), , )
.ContinueWith ( (t) =>

         {
            this.InvokeOnMainThread(() => { loadingView.Hide (); });
                            
            var result = t.Result;
                            
            if (result != null && result.IsSuccess && result.Payload != null)
            {
               this.InvokeOnMainThread(() => 
                {
                  AppDelegate.Current.UserInfo = result.Payload;
                  MoveToHomeView();
                                        
                 });
             }
             else
             {
                this.InvokeOnMainThread(() => {
                    new UIAlertView(Invalid login, Invalid username or password., null, OK).Show();
                    });
             }
     });

I wrote a simple generic method for making POST calls to MVC4 WebApi for use on Windows Phone 8 (But you can use it elsewhere).  The idea is simple: Create one set of generic methods that will take a generic TResultType, an Api Uri, and optionally some data to post and return back a strongly typed response object.

Usage is simple:

This allows you to simply use await to make your MVC4 WebApi calls and get back strongly typed objects.  The Post code uses Newtonsoft Json library to deserialize the response string as an object.

I will package this up as a simple GIT project when I have time and create a nuget package so that everyone can use this simply.

While building a small application for viewing passwords (basically pwsafe for Windows Phone 8) I realized that because of the restrictions of WP8 with regard to the file system I needed a way to pull password files from a remote storage.  As it turns out, the SkyDrive API is comprehensive but did not have a concise Windows Phone 8 API so I started building one.

https://github.com/dsandor/SkydriveHelper

The code is very basic at this point but I do intend on improving it.

With the API helper you can:

These commands will allow you to do the majority of what you need (except upload).

To use it, simply place a SignInButton found in the Microsoft.Live.Controls assembly for Windows Phone 8.  On the OnSessionChanged event simply pass the Session to the helper and it is ready to go.

There is a very simple sample application included in the source tree that will let you get the directories from the skydrive and download a file.

This is a pretty rookie mistake with .NET 4.5 and the new async / await operators.  While searching for the answer I found a lot of noise and no valuable answers so I thought I would notate the solution on my blog.

The short answer is that any method that uses await must itself be marked with async.

Take this code for example:

Error    2    The ‘await’ operator can only be used within an async method. Consider marking this method with the ‘async’ modifier and changing its return type to ‘Task’. 

This problem has been solved and answered many different ways but none of the answers seem to propose a complete basic or step by step solution.  This article is my attempt to consolidate the answer into one concise how to article.

Executive Summary

For those of you that want the answers quickly, here are the steps necessary to properly use WebGet methods in a WCF Service:

  1. Use the WebGet attribute and specify a UriTemplate.
  2. Use the webBinding binding type in your web.config.
  3. Create an endpoint behavior that specifies webHttp in your web.config.
  4. Reference the endpoint behavior in the service endpoint configuration section.
  5. Set the binding in the service endpoint configuration to webHttpBinding (or to the name of the binding configuration that specifies webHttpBinding).

How-To / Step by Step

In this section we will go through the process of creating a simple service with Visual Studio 2010 that performs a simple WebGet operation.

Create a new WCF Service Application project.

image

I am going to leave the default Service1 class and interface names intact for simplicity.

Open the IService1.cs code file and change it so that it looks like this:

Note the WebGet attribute in the interface definition.  Now we are going to modify the Service1.cs file to implement the AddNumbers method.

This implements the method.

Compile the project and make sure it builds. Next we are going to update the web.config file so this actually works.

In Visual Studio click Tools | WCF Service Configuration Editor, Load the web.config file for this new project.

image

You will see the WCF Config Editor.

Now we are going to create a Service Endpoint and an Endpoint Behavior.

Click the Services configuration node and click Create a New Service.

Click Browse to find the service type.  You are going to navigate to the DLL that implements your WCF service (hint, it should be in your /bin folder).

image

After clicking Open you will be allowed to choose the class that implements your service.  Click it and then click Open.

image

After clicking Open you will click Next.  This will bring you to the service contract screen.  This screen is asking you what the interface is that describes your service.  Typically this will be automatically detected and filled out for you.

image

Click Next.

image

Choose HTTP and click Next.

image

Choose Basic Web Services interoperability and click Next.

For the Endpoint Address enter / and click Next then on the summary page click Finish.

image

You will now have a service configured in your Web.config file.

image

Now we will create an endpoint behavior.  Expand Advanced, Right Click on Endpoint Behaviors and choose New Endpoint Behavior.

image

Click Add, Choose webHttp and click Add.

image

The new behavior configuration screen will now look like this:

image

Change the Binding to webHttpBinding and select the NewBehavior0 behavior configuration.

image

Click Save and exit from the WCF Service Configuration tool.

Now you should be able to start your WCP project and navigate to the web method in your browser and see a result like below.

image

Note that the URL contains your .svc file and then the UriTemplate property of the WebGet attribute kicks in. 

Source code for this project: WebGetTest.zip