First NETMF Project

Last modified May 19, 2015

Software Setup

Follow the setup instructions on our .NET Micro Framework support page.


All example code should be copied directly from this document and pasted into the Visual Studio program editor.

The pictures used in this tutorial may vary slightly with different versions of the development platform.

The Emulator

The NETMF SDK includes an emulator for running NETMF applications on the PC. For the first part of this project, the emulator will be used to run a very simple application; after that, the same program is run on NETMF hardware.

Create a New Project

Open Visual Studio, select FILE->New Project. There should be a “Micro Framework” option in the left menu. Click on it, select “Console Application”.

Click the “OK” button a project and program are created. The project has only one C# file, called Program.cs. C# source files are listed in the “Solution Explorer” window. If the Solution Explorer is not opened, use the VIEW->Solution Explorer menu.

Double click on Program.cs to open the file in the editor.

using System;
using Microsoft.SPOT;

namespace MFConsoleApplication1
    public class Program
        public static void Main()


For simplicity change the code to match the listing below:

using Microsoft.SPOT;

public class Program
    public static void Main()

Selecting Transport

When compiling a NETMF Console Project, there are options in Video Studio that control where the program is loaded and run.

Select the menu item for the project's properties:


In the Properties window, on the left side tabs, select “.NET Micro Framework” and make sure that "Transport:" is "Emulator."


Console applications have their "Debug.Print" statements appear in Visual Studio's "Output" Window. The application in this example uses print statement; so, if the Output window is not visible, use the "VIEW->Output" menu item.


Press F5 and Visual Studio will compile the program, load it into the emulator and run it.  The emulator displays a hypothetical NETMF device, complete with buttons and a screen. Do not close it.


After a few seconds, the program will stop and the Output window will have "Amazing!" printed (surrounded by other application information).


Introduction to Debugging

The following sections are a quick introduction to the power and ease of debugging NETMF applications.

Start running the program by pressing F11 (instead of F5), this will “step” into the application instead of just running it; after deployment, the program starts to run and stops at the very first line of the code. This is indicated by the yellow arrow.


Press F11 to step to the "Debug.Print" statement. Finally, after pressing F11 one more time, "Amazing!" is printed in the Output window. Press F5 to let the program run to completion.


Setting breakpoints is simple! -- Click in the bar to the left of the line that prints “Amazing!” A red dot appears to mark the breakpoint location.

Press F5 to run the software. When the application reaches the breakpoint the debugger will pause:

F11 can be used to single step execution line by line. F5 can be used to let the program run.

Running on Hardware

Deploying and running NETMF applications on hardware is very simple -- connect the hardware, change an option in Visual Studio; after that, all loading, running, debugging, etc. are done using the NETMF processor. The complete procedure is described below.


When working with hardware, take care not to expose the hardware to static electricity as it can damage the components.

Connect and Power-up

Connect the NETMF hardware to the PC using a USB cable. This is done one of two ways.

  1. If the processor has a USB connector integral to the circuit board and the board is colored red, plug a USB cable from the computer directly to the board.
  2. Processors without an integral USB port will use a Gadgeteer socket to connect the power/USB module to the board. For these boards connect the power module to a "D" labeled socket on the board, then connect the power/USB module to the computer. (These mainboards are black)..

The first time a processor is connected to the computer, Windows will need to load a driver. Before proceeding, wait until the driver is fully loaded.


Updating Device Software

Before using the NETMF device, the embedded software must match the version of the SDK being used. Descriptions and procedures for updating the embedded software are explained in either of two documents:

  1. step-by-step guide with brief explanations (a quick how-to for getting started).
  2. detailed explanation followed by instructions.

If necessary, use one of the above documents, and then return here to continue the tutorial.

Skipping the above step is the most common problem faced by beginners.


Many USB hubs are poorly implemented in PCs. If Windows failed to recognize the NETMF device or had any connection problems then make sure the device is connected directly to the PC, not through a USB hub. If problems persist, try using a power transformer or powered-USB-hub to guarantee the device is getting sufficient power (see also the USB sections in NETMF Troubleshooting).

Deploying to Hardware

Once the board is connected, Visual Studio has a control to switch back and forth between the emulator and connected hardware.

From the project properties, select USB for transport.. Make sure the setup looks similar to the image below:

Pressing F5 sends the simple application to the hardware and runs it. Debugging works exactly the same as described above.

Next Steps

All NETMF related tutorials are locarted at

Leave feedback about this document.
Let us know if the information presented here was accurate, helpful and if you have any suggestions.
Leave feedback about this document.
Let us know if the information presented here was accurate, helpful and if you have any suggestions.

* Indicates required fields.
This form is only for feedback not support.
Review our how to find information guide on locating helpful resources.