WARD.NU
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:

filenameaction
NE8A18~1.000remove
0mscoree.001remove
MSCORE~1.002remove
cgacutil.003remove
NETCF1~1.004remove
NETCFA~1.005remove
CALEND~1.006remove
CHARIN~1.007remove
CULTUR~1.008remove
CULTUR~2.009remove
REGION~1.010remove
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
NETCF_~1.999remove

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
HelloWorld.cs


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.


Hints