.NET Technical Overview
From Symbian Developer Community
| Warning http://www.redfivelabs.com/ are closing down. At time of writing the status of the Net60 product is as yet unclear (see link for more information). |
| For Technical Review This page is ready for technical review. The author(s)/editor(s) believe(s) that it is complete but that it now requires technical review by a subject expert. If you have the expertise to review the article, please feel free to do so, and either edit it directly or add comments for the author using the box at the bottom of the page (or both). Further suggestions about how to carry out a technical review are provided in the Document Creation Workflow page |
This article describes Net60, from Red Five Labs, which is the de facto .NET framework for the Symbian platform. Net60 enables mobile applications, built for Windows Mobile using .NET Compact Framework v2.0, to run on the Symbian platform.
This article is intended for the following audience:
- Symbian developers familiar with native C++ development taking their first steps into C# and .NET on Symbian.
- Enterprise application developers planning to migrate .NET applications to Symbian and S60 devices.
- Mobile developers wishing to create cross-platform .NET solutions for Symbian and Windows Mobile.
The article focusses on the Net60 tools and development practices required to run .NET mobile applications on Symbian phones.
| Note Net60 is now Symbian^1 Compatible! On 13/7/2009, Red Five Labs release Net60 version 2.2 with full support for S60 5th Edition touch UI[1] |
Contents |
Technical Overview of Net60
The .NET Compact Framework is a subset of the full .NET platform designed by Microsoft for mobile applications on Windows Mobile. Red Five Labs provides Net60, the .NET Compact Framework on Symbian.
Microsoft originally designed and developed the .NET platform with support for multiple languages and operating systems. The European Computer Manufacturers Association (ECMA) subsequently approved the C# language and the Common Language Infrastructure (CLI) as Standards 334 and 335 respectively.
Red Five Labs implemented the Common Language Infrastructure (commonly referred to as .NET) on the Symbian platform as depicted in the simplified architectural diagram below.
As the diagram shows, the .NET runtime is analogous to the Java Virtual Machine. Instead of writing native Symbian C++ code for the underlying Symbian operating system, .NET developers write managed C# code which targets a managed execution environment common to Symbian and Windows Mobile.
Net60 Capabilities
Net60 is provided in the form of a Software Development Kit (SDK) for Windows XP and Vista which plugs into the Visual Studio suite of IDEs.
.NET CF 2.0 applications installed on Symbian devices are first-class-citizen applications like any other Symbian C++ app. Developers create Symbian Installation Source (SIS) files using the Genesis plug-in for Visual Studio.
The Net60 SDK is compatible with:
- Symbian^1
- Microsoft .NET Compact Framework 2.0
- Symbian OS 9.1 onwards
- S60 3rd & 5th edition (5th edition devices are supported in a preview beta)
- Windows Mobile 5 (PocketPC and Smartphone)
- Windows Mobile 6 (Professional and Standard)
- On-device databases such as SQLite (through a standard ADO.NET data provider)
- XML web services
- Native S60 UI look and feel
Supported User Interface Controls
The Symbian platform powers both touch and non-touch enabled devices. These are broadly equivalent to the form factors of Windows Mobile Professional and Windows Mobile Standard projects respectively.
Net60 supports touch operation in those controls that need to be touch aware. Below is a list of the touch and non-touch controls that are provided as part of Net60.
| Windows Mobile Standard
(non touch phones) | Windows Mobile Professional
(touch phones) |
|---|---|
|
|
The Red Five Labs Mobility Framework
Mobile application developers often need to use functionality not provided in the .NET CF to access underlying device APIs such as GPS and telephony. The Mobility Framework extends the managed API provided by Net60 with the following APIs:
- Messaging (send and receive SMS and email)
- Location (from GPS)
- PIM (read and write contacts and calendar items)
- Call functions (dial, answer and terminate a call)
- OpenGL
- Vibration
The Mobility Framework is a cross-platform solution for Windows Mobile and Symbian. It publishes a single API across both platforms so that device features and services can be accessed without the need for platform conditional invocation.
Enterprise Mobility Applications
Enterprises, system integrators and independent software developers commonly standardize on the use of .NET technologies. In such cases, the .NET Compact Framework is the primary mechanism for extending line-of-business (LOB) applications to the mobile platform.
Besides the commonality offered by .NET CF for Windows Mobile and Net60 for Symbian, which allows a common code base, the XML web services and .NET networking stack also enhance developer productivity.
The C# Language
C# and the .NET framework offer a next-generation programming experience. Many of the issues that make native code development challenging, such as memory corruption, invalid pointers, resource leaks and type mismanagement, are handled by the underlying Common Language Runtime (CLR).
Symbian C++ developers must use the clean-up stack and be very careful with memory and resource management. In .NET memory management is handled by the CLR and its inbuilt garbage collector. The developer, on the whole, does not need to be concerned with object and resource management because the CLR knows when an object is safe to destroy. Likewise, because of its strong type checking, the CLR ensures type safety.
In addition to the CLR, the .NET framework includes prebuilt and tested functionality to provide services such as network access, data-structure manipulation and XML parsing. This is the framework class library or FCL.
C#, and the C# programming paradigms, were specifically designed to be easy for C and C++ developers to learn and use.
This C# code example shows the classic “Hello, World” program.
using System;
class Hello
{
static void Main() {
Console.WriteLine("Hello, World");
}
}
Versions
Net60 was released commercially on 1 April 2008. The product has evolved according to the version table below. Net60 Version 2.2 was released as free product for non-commercial use.
| Net60 Version | Year Released | .NET CF Compatibility | S60 Version | Symbian | Highlights over previous version |
|---|---|---|---|---|---|
| 1.0 | Q1 2008 | 1.0 | 3rd edition | n/a | - |
| 2.0 | Q4 2008 | 2.0 | 3rd edition | n/a | Includes System.Collection.Generic
ADO.NET data provider for SQLite Genesis Visual Studio Plug-in |
| 2.1 | Q1 2009 | 2.0 | 3rd & 5th edition | Symbian^1 | Partial support for S60 5th edition (aka Symbian^1) touch devices.
Mobility Framework beta extension |
| 2.2 | 13th July 2009 | 2.0 | 3rd & 5th edition | Symbian^1 | Full support for Symbian^1 and S60 5th edition.
Mobility Framework V1.0 release |
Getting Started with Net60
The Net60 SDK makes building applications for the Symbian platform easy and efficient by making effective use of the best tools available for developing .NET applications.
Executables that run on Windows Mobile also run on Net60 on Symbian. This is because the Net60 CLR uses the same Intermediate Language (IL) code as the Windows Mobile CLR.
Developing .NET CF binaries for the Symbian platform follows the vanilla workflow of .NET development. Developers use Visual Studio, C# and a Windows Mobile device emulator to write and debug code up until the point that the .NET .exe is output.
From that point onwards, the typical development cycle consists of taking the 'vanilla' .NET application and identifying the features that are custom to the Symbian platform, such as GPS or Telephony, and providing platform-specific implementations for them. The relevant code is written with different (platform-specific) execution paths.
The final step is to generate the installation file for the Symbian device. The process is described in a ‘HelloWorld’ web demo on Red Five Labs’ website.
Click here to watch the demo.
Pre-requisites
To develop applications in C# (and Visual Basic), you require Visual Studio 2005 or 2008 (Standard, Professional or Team edition) and the Net60 SDK (click here to download SDK). This combination allows you to develop .NET CF-compliant applications suitable for running on a Symbian device. Visual Studio provides an IDE and emulators to help you debug your C# applications, which substantially reduces the write, run and debug cycle. A suitable Windows Mobile SDK might also be required.
A 30-day evaluation license for Net60 is available immediately after supplying the device IMEI to be licensed: Click here for an evaluation license.
Net60 SDK
The Net60 SDK comprises the distributable .NET CF on-device installer (Net60.sisx) and the tools required to deploy .NET executables to the Symbian platform.
The Genesis Visual Studio plug-in, which ships with the Net60 SDK, creates SIS files from .NET .EXEs. You must add a Genesis project to your Visual Studio application project. The Genesis wizard automates the steps involved in configuring properties such as application UIDs and security capabilities.
Genesis packages your project (HelloWorld.exe) into a SIS file (HelloWorld.SIS) which can be installed onto a device.
Before your application can run on a Symbian device, however, the .NET Compact Framework must also be installed. Red Five Labs provides a signed, distributable Net60 installation SIS which can you include in your SIS file.
To reduce the build-deploy-debug development cycle Red Five Labs provides the ‘Net60 Launcher’ which is a file explorer that launches .NET .EXEs from specific folders on the device. This circumvents the need to create .SIS files at each iteration as executables can be copied directly to the phone and run.
For debugging on a device, the SDK includes the Red Five Labs Log Viewer which you can use to view the runtime log files after an application has executed.
Example
This example builds a small application that accepts a URL as input, retrieves the HTML source code and puts it into an edit control. It illustrates the high level of .NET and C# support available in Net60 by providing examples of forms, delegates, network operations, asynchronous processes, HTTP transactions, thread pools and streams.
Good design practice dictates that an application should be designed in layers. At a minimum, the user interface layer and business logic layer should have separate areas of responsibility. This approach is used in the example. The HTTPEngine class encapsulates an asynchronous implementation of the engine, which fetches a specified URL, and the WikiForm class issues the request to the engine and handles the response, thus encapsulating the user interface design.
As the design should be familiar to most C# developers, there is little further elaboration required except that the public function FetchURL() starts the HTTP session. The majority of the code resides in the RespCallback() method, called once the transaction completes. This delivers the response via another delegate to the user interface layer (WikiForm).
The RequestState() object is a bridge object that holds state between the transaction calls and allows the delegate (or callback) from the UI layer to be a member of the asynchronous response
public class RequestState
{
public HttpWebRequest Request ;
public TransactionCompleteDelegate Callback ;
}
internal class HttpEngine
{
public delegate void TransactionCompleteDelegate( string content );
public void FetchUrl( string url, TransactionCompleteDelegate callback )
{
HttpWebRequest req = ( HttpWebRequest )HttpWebRequest.Create( url ) ;
RequestState state = new RequestState() ;
state.Request = req ;
state.Callback = callback ;
IAsyncResult result = ( IAsyncResult )req.BeginGetResponse( new AsyncCallback( RespCallback ), state ) ;
}
private static void RespCallback( IAsyncResult asyncResult )
{
RequestState state = ( RequestState )asyncResult.AsyncState ;
try
{
HttpWebResponse resp = ( HttpWebResponse )state.Request.EndGetResponse( asyncResult ) ;
StreamReader reader = new StreamReader( resp.GetResponseStream() ) ;
string httpContent = reader.ReadToEnd() ;
state.Callback( httpContent ) ;
}
catch ( Exception e )
{
state.Callback( e.Message ) ;
}
}
}
Most of the user interface code is simple and maintained by the user interface designer, so is not included in this article. The two methods of significance are the method to launch the transaction and the callback function (Delegate()) when the transaction completes.
The first method checks to see if there is already a transaction ongoing and, if not, issues the request together with the callback object (Done) to be called when the transaction completes.
private void MenuItemFetch_Click( object sender, EventArgs e )
{
if( this.engine == null )
{
try
{
this.engine = new HttpEngine() ;
this.engine.FetchUrl( this.txtUrl.Text, new HttpEngine.TransactionCompleteDelegate( Done ) ) ;
Cursor.Current = Cursors.WaitCursor ;
}
catch( Exception ex )
{
this.Done( ex.Message ) ;
}
}
else
{
MessageBox.Show( "The engine is already running", "WikiExample", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1 ) ;
}
}
The second method is the Delegate() method and is called when the transaction object completes. This checks the thread on which the callback was made and, if it is not the same as the user interface, the delegate is re-issued and will continue to be re-issued until the underlying thread pool chooses the UI thread, where it is then safe to update the contents of the control.
private void Done( string content )
{
if( this.InvokeRequired )
{
HttpEngine.TransactionCompleteDelegate retry = new HttpEngine.TransactionCompleteDelegate( this.Done ) ;
this.Invoke( retry, new object[] { content } ) ;
}
else
{
this.txtContent.Text = content ;
this.engine = null ;
Cursor.Current = Cursors.Default ;
}
}
This code functions the same in Windows Mobile and Net60.
Working with Net60 on the Symbian platform
There are a number of reasons to choose .NET on Symbian as a development approach. They include:
- large existing .NET developer pool,
- re-use of existing code,
- short project time lines where a measurable ROI is required.
Vanilla .NET CF 2.0 applications run unchanged on Net60 and require little more than the addition a Genesis project to create a Symbian SIS file.
Mobile applications, however, might use device specific hardware not provided for in the .NET CF. There are a number of ways of using the extensibility of Net60 to meet such requirements:
- Red Five Labs provides managed APIs for common device features such as messaging, location and PIM in the Mobility Framework as described above.
- Third party vendors provide managed implementations of missing functionality which can be integrated into Net60 projects.
- .NET provides the necessary architecture to interface directly with the Symbian platform an unmanaged C++ DLLs.
Interfacing with the Symbian Platform
One of the strengths of the .NET platform is its ability to get out of the ‘sandbox’ and access system and user-developed services and extensions in C/C++.
This is done using the P/Invoke or platform invoke functionality which allows calls to unmanaged (native) DLLs, in the same way as any other native application. Moreover, the Net60 CLR ensures that the primary process thread has both a trap harness and an active scheduler installed so the ‘plumbing’ for a typical Symbian platform native code application is already installed.
See the Red Five Labs website for an example of using P/Invoke.
Packaging and distribution
.NET applications are distributed for installation on Symbian phones as native Symbian SIS install packages. Genesis, the tool provided by Red Five Labs, generates these SIS files from .NET .exes.
Dependencies can be added to the generated SIS files. Third party DLLs and embedded SISs can be deployed at install time. Examples of this packaging functionality might be to install an embedded database or native Symbian C++ DLL as part of a transaction engine.
Symbian applications created with Net60 can be widely distributed and run on all 3rd and 5th edition phones. Red Five Labs also provides the ability to license end user applications according to a number of different parameters such as device type, duration, network operator or individual IMEI.
How to test applications
The first phase of application testing is usually done using the device emulators provided in the Visual Studio IDE. Visual Studio provides device emulators for the various Windows Mobile form factors, such as Professional and Standard (Professional refers to PocketPC-style touch applications whilst Standard refers to non-touch smartphone specific form factor). At compile time it is trivially easy to deploy the built .NET binary to these emulators to debug the application.
The second phase of testing is on-device testing. Using the Net60 Launcher, .NET binaries can be run directly on the phone by simply copying them across. There is no need to wrap up the binary into a SIS file until the application is ready to be released. The execution log generated on the phone can be viewed with the supplied Log Viewer.
Developers with restricted access to Symbian-based devices may also use a service provided by Nokia called Remote Device Access where physical devices are accessible through an online portal.
Security
The Symbian platform has a capability-based security model. A capability is a token of authority that grants access to particular Symbian APIs. The Symbian OS platform security model defines 20 capabilities with the most common being permission to read and write the device user's local data. An application that uses a protected API must must be Symbian Signed with the appropriate capability.
Symbian Signed is equivalent to Microsoft’s Mobile2Market code signing process.
The Genesis SIS creator provides support for developers wishing to Symbian Sign their applications. There are a number of signing options available and Genesis supports both Open and Self-Signing. A comprehensive presentation on Symbian Signing applications with Net60 is available in the form of a web demo.
For further information about Symbian Signed, see here
Tools
Red Five Labs provides the following developer tools:
- Genesis – SIS file generator which uses .NET .exes as input.
- Net60 Launcher – On-device explorer which launches .NET .exes directly.
- Log Viewer – PC-based viewer for .NET application execution log files.
Microsoft Development Network (MSDN) maintains a list of third party tools which are relevant to .NET development.
Wikipedia maintains a .NET programming tools category with notable mentions being the code analysis tools FxCop and StyleCop.
Summary
The binary compatible version of the .NET Compact Framework provided by Red Five Labs makes porting the major components of a Windows Mobile smartphone application to the Symbian platform quick, often requiring only minor changes to get the same application running on a Symbian or S60 device.
Net60 provides you with new opportunities to find the right balance between access to low-level Symbian features and development complexity. The large collection of standardized classes in the framework library makes code re-use a reality.
As the Symbian platform continues to evolve, offering users the leading smartphone devices while offering developers the innovative tools to deliver applications to those devices, Net60 will be an integral part of enabling the familiar .NET environment.
You can download Net60 Version 2.2 for free by sending your e-mail address and a valid IMEI code through this URL http://www.redfivelabs.com/net60/Explore.aspx
Further information
- Wikipedia article on .NET.
- Wikipedia article on the C# programming language.
- .NET Development on S60 booklet by Symbian Press (superseded by this article)
- 'Getting Started with Net60' Web Demo.
- Net60 data sheet.
- Net60 FAQ.
- Red Five Labs' Net60 Quick Start guide.
Glossary
| .NET | - commonly used term to refer to the Common Language Infrastructure which provides the necessary managed environment to run C# applications. |
| .NET CF | - .NET Compact Framework, a subset of the .NET framework that is designed for mobile devices. |
| IL | - Intermediate Language also known as .NET byte code. |
| CLI | - Common Language Infrastructure. |
| CLR | - Common Language Runtime. |
| Visual Studio | - Micrsoft’s IDE and required for .NET CF development. |
| S60 | - Series 60, Nokia’s platform for smartphone development. |
| Net60 | - Red Five Labs’ implementation of the .NET Compact Framework for S60 devices. |
| SQLite | - Open-source SQL database platform with mobile device support. |
Comments
Sign in to comment…








