Category Archives: frameworks

How does Xamarin.IOS aka monotouch work?

Xamarin is a software development framework that allows developers to build applications for iOS and Android platforms using c# and the .Net framework. The SDK has separate requirements for developing iOS and Android application. The part of the SDK targeting iOS development is referred to as Xamarin.iOS or monotouch (the original name of the project)

Requirements for developing iOS applications using Xamarin.iOS
Apple Macintosh Computer Running OSX Lion or greater (10.7 >)
Apple Developer Program membership $99 per year, allows downloading of iOS SDK and publication of applications to the Apple app store
iOS SDK and Xcode Required during compilation, and optionally can be used to design graphical user interfaces using it’s inbuilt graphical designer
iOS Device Simulator Part of the SDK allows running of applications during the development process
Xamarin studio or Visual Studio Not strictly necessary, however does automate the build process
Knowledge of c# c# is the main language supported by Xamarin.iOS

Table 1 (Xamarin, Inc)

Mono is an open source implementation of the .NET Framework which can run across multiple operating systems, Windows, Linux and OSX. Mono is based on ECMA standards and is ABI (application binary interface) compatible with ECMA’s Common language infrastructure (CLI).

Xamarin.iOS compiles c# source code against a special subset of the mono framework. This cut down version of the mono framework includes additional libraries which allow access to iOS platform specific features. The Xamarin.iOS compiler, smsc, takes source code and compiles it into an intermediate language, ECMA CIL (common intermediate language), however it does not produce ECMA ABI compatible binaries unlike the normal mono compiler, gmcs or dmsc. This means any 3rd party .Net libraries you want to include in your application will need to be recompiled against the Xamarin.iOS subset of the mono framework using smsc.

Once a Xamarin.iOS application has been compiled into CIL it needs to be compiled again into native machine code that can run on an iOS device. This process is carried out by the SDK tool ‘mtouch’, the result of which is an application bundle that can be deployed to either the iOS simulator or an actual iOS device, such as an iPhone or iPad.

Diagram showing how monotouch aka xamarin.ios works?

Due to restrictions placed by Apple, the iOS kernel will not allow programs to generate code at runtime. This restriction has severe implications for software systems that run inside a virtual machine using just-in-time compilation. Just-in-time compilation takes the intermediate code, for example mono CIL and compiles it at runtime into machine code. This machine code is compatible for the device it is running on at the time of execution.

To work around this restriction the mtouch tool compiles the CIL ahead of time. A process that the mono team describe as AOT, ahead of time compilation. See: http://docs.xamarin.com/guides/ios/advanced_topics/limitations

Tagged , ,

Running nuget on mono

Well the documentation states that the nuget command-line tool does indeed work with mono

Does NuGet support Mono?

The command-line application (nuget.exe) builds and runs under Mono and allows you to create packages in Mono.

So I merrily install nuget to my home directory ~/. Run the command mono ~/nuget and get the error message:

Problem

WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v2.0.50727

Screen Shot 2012-05-06 at 11.04.32

Solution

Turns out the simple solution is to specify the absolute .net version:

mono –runtime=v4.0.30319 NuGet.exe

 and voila!

Screen Shot 2012-05-06 at 11.11.57

Tagged ,

What is the current state of REST frameworks in .Net 4.0

WCF WebHttp Services in .NET 4

Part of the official .Net 4.0 framework release.

WCF WebHttp Services is the flavor of WCF that is most appropriate for developers who need complete control over the URI, format, and protocol when building non-SOAP HTTP services— services that may or may not subscribe to RESTful architectural constraints.

Documentation

http://msdn.microsoft.com/en-us/library/bb412169.aspx

Example

Introducing WCF WebHttp Services in .NET 4: http://blogs.msdn.com/b/endpoint/archive/2010/01/06/introducing-wcf-webhttp-services-in-net-4.aspx

WCF WebApi

This project focuses on allowing developers to expose their apis for programmatic access over HTTP by browsers and devices.

Essentially this is a continuation of work done on the WCF Rest starter kit, and could be considered as a preview of wcf http services for .net 5.0?

WCF REST Starter Kit (depreciated)

The new WCF Web Api’s recently announced at PDC replace the REST Starter Kit and provide significant enhancements including better access to HTTP, more flexibility with representations and support for jQuery. Please go to http://wcf.codeplex.com/ for more information.

Source: http://aspnet.codeplex.com/wikipage?title=WCF%20REST&ProjectName=aspnet

Open Rasta

OpenRasta is a development framework targeting the Microsoft .NET platform for building web-based applications and services, and distributed under an Open-Source MIT License.

By focusing development around resources and HTTP methods, OpenRasta simplifies the creation of ReST-friendly interfaces.

Example

How to create a rest service using Open Rasta: http://blogs.7digital.com/dev/2011/02/02/rest-in-practice-and-openrasta/

RestSharp

http://restsharp.org/ A client only api for consuming rest services

RestSharp is a simple, open source REST client for .NET designed primarily for consuming third-party HTTP APIs. RestSharp is NOT:

  • A REST server framework
  • A SOAP client
Tagged , ,