Return to WWW.WARD.NU

Compiling .NET CF (Pocket PC) applications without Visual Studio.NET

Last updated 20030526 - I was recently notified of the link http://msmobiles.com/article.php/35.html. This page also shows this procedure, written in the same timespan. Although Microsoft insists (see usenet) that you can not compile .NET Compact Framework (.NET CF) applications without owning Visual Studio .NET, it is in fact possible. Applications for the normal .NET Framework can be compiled using the free .NET SDK. When you compile .NET CF applications, you need to reference different "assemblies". Those assemblies are not included in the .NET SDK, and can not be downloaded separately from the Microsoft website. Or can they?

Obtaining the necessary files

You need to download the following files:

Install the .NET SDK. Afterwards, install the .NET Compact Framework. Navigate to the directory where you have installed your .NET CF. You will find a file named "netcf.core.ppc3.arm.cab". Open this file using explorer and extract all the files into a separate directory. These are the files you need, you just need to rename them to the proper names, according to this table:

mscorlib.011rename to mscorlib.dll
00system.012rename to system.dll
SYD8C9~1.013rename to system.drawing.dll
SY17B8~1.014rename to system.web.services.dll
SY5DD4~1.015rename to system.windows.forms.dll
SY9B57~1.016rename to system.windows.forms.datagrid.dll
SY40C7~1.017rename to system.xml.dll
SYB769~1.018rename to system.net.irda.dll
SYSTEM~2.019rename to system.data.dll
MICROS~2.020rename to microsoft.visualbasic.dll
MICROS~3.021rename to microsoft.windowsce.forms.dll

Alternatively, you can download the batch file convertnet.bat to do this step for you.

Compiling an application

Now you have everything you need. Open a Command Prompt and execute the file "sdkvars.bat" in the \BIN directory of your .NET SDK directory. Now you can compile any .NET CF compliant source code. Please notice: most of the examples in the .NET Framework SDK will not compile without altering some of the source code.
To compile a .NET CF application, execute the following command (substitute d:\net\cf\dll in the directory where you have extracted the .CAB file):

csc /noconfig /nostdlib /r:d:\net\cf\dll\mscorlib.dll /r:d:\net\cf\dll\system.dll
/r:d:\net\cf\dll\system.drawing.dll /r:d:\net\cf\dll\system.windows.forms.dll

Compiling a sample application

As an example, we'll compile my Teletekst application. Extract the referenced zip file into a new directory.
To compile, execute the following command (substitute d:\net\cf\dll in the directory where you have extracted the .CAB file):

csc /noconfig /nostdlib /r:d:\net\cf\dll\mscorlib.dll /r:d:\net\cf\dll\system.dll
/r:d:\net\cf\dll\system.drawing.dll /r:d:\net\cf\dll\system.windows.forms.dll
/target:winexe /out:nosttnet.exe /win32icon:Teletekst.ico
/resource:Teletekst.resources Teletekst.cs

For more information regarding this application, visit this page.