Persisting .Net Framework on CE Devices

I thought I'd share my experiences on getting .NET to persist after a cold boot.

This is intended as a guide only. The devices I used are the Motorola WT4090 and Motorola MC3190 but the process should work for all CE devices. No guarantees are given, however.

The samples given are for the ARMV4i architecture only.


I'm not sure on the legality of sharing files (even redistributables) so I'm afraid I won't share any files but I will share the process I followed to get this working.

Placing the .NET redistributable .CAB file in the \Application folder has two bad side effects;

Firstly, the file is deleted once exploded if run from it's current position
The installation is very slow, often taking longer than your system waits for your .NET application to start - so your application fails to load because the framework is not there.

The workaround is to take the redistributable .NET installation cab file and remove the files it simply copies and place these is a sub folder in the \Application folder of your device.

I will include the .NET 3.5 ARMV4I script I created for our Motorola WT4090 and Motorola MC3190 devices;

File NET35.CPY:

\Application\NET35\cgacutil.exe.400~499~ARMV4 > \Windows\cgacutil.exe.400~499~ARMV4
\Application\NET35\cgacutil.exe.400~499~ARMV4I > \Windows\cgacutil.exe.400~499~ARMV4I
\Application\NET35\cgacutil.exe.500~699~ARMV4I > \Windows\cgacutil.exe.500~699~ARMV4I
\Application\NET35\CustomMarshalers.dll > \Windows\CustomMarshalers.dll
\Application\NET35\Microsoft.VisualBasic.dll > \Windows\Microsoft.VisualBasic.dll
\Application\NET35\Microsoft.Windowsce.Forms.dll > \Windows\Microsoft.Windowsce.Forms.dll
\Application\NET35\Microsoft.WindowsMobile.DirectX.dll > \Windows\Microsoft.WindowsMobile.DirectX.dll
\Application\NET35\mscoree.dll.400~499~ARMV4 > \Windows\mscoree.dll.400~499~ARMV4
\Application\NET35\mscoree.dll.400~499~ARMV4I > \Windows\mscoree.dll.400~499~ARMV4I
\Application\NET35\mscoree.dll.500~699~ARMV4I > \Windows\mscoree.dll.500~699~ARMV4I
\Application\NET35\mscorlib.dll > \Windows\mscorlib.dll
\Application\NET35\netcfagl3_5.dll.400~499~ARMV4I > \Windows\netcfagl3_5.dll.400~499~ARMV4I
\Application\NET35\netcfagl3_5.dll.500~699~ARMV4I > \Windows\netcfagl3_5.dll.500~699~ARMV4I
\Application\NET35\netcfd3dm3_5.dll.400~499~ARMV4I > \Windows\netcfd3dm3_5.dll.400~499~ARMV4I
\Application\NET35\netcfd3dm3_5.dll.500~699~ARMV4I > \Windows\netcfd3dm3_5.dll.500~699~ARMV4I
\Application\NET35\System.Core.dll > \Windows\System.Core.dll
\Application\NET35\System.Data.dll > \Windows\System.Data.dll
\Application\NET35\System.dll > \Windows\System.dll
\Application\NET35\System.Drawing.dll > \Windows\System.Drawing.dll
\Application\NET35\System.Messaging.dll > \Windows\System.Messaging.dll
\Application\NET35\System.Net.Irda.dll > \Windows\System.Net.Irda.dll
\Application\NET35\System.Runtime.Serialization.dll > \Windows\System.Runtime.Serialization.dll
\Application\NET35\System.ServiceModel.dll > \Windows\System.ServiceModel.dll
\Application\NET35\System.Web.Services.dll > \Windows\System.Web.Services.dll
\Application\NET35\System.Windows.Forms.dll > \Windows\System.Windows.Forms.dll
\Application\NET35\System.Xml.dll > \Windows\System.Xml.dll
\Application\NET35\System.Xml.Linq.dll > \Windows\System.Xml.Linq.dll
\Application\NET35\mscoree.dll > \Windows\mscoree.dll
\Application\NET35\netcfagl3_5.dll > \Windows\netcfagl3_5.dll
\Application\NET35\netcfd3dm3_5.dll > \Windows\netcfd3dm3_5.dll
\Application\NET35\Microsoft.VisualBasic.SR.dll > \Windows\Microsoft.VisualBasic.SR.dll
\Application\NET35\NETCFv35.Messages.EN.gac > \Windows\NETCFv35.Messages.EN.gac
\Application\NET35\System.SR.dll > \Windows\System.SR.dll
\Application\NET35\Microsoft.VisualBasic.SR.dll > \Windows\Microsoft.VisualBasic.SR.dll
\Application\NET35\System.Data.DataSetExtensions.dll > \Windows\System.Data.DataSetExtensions.dll


These files are now removed from our .CAB file. If you have any knowledge of creating CAB installations for CE in Visual Studio, I'd strongly recommend you use this to install the remaining items, otherwise, you can edit the _setup.xml file contained in the redistributable .NET cab file to remove references to the files you removed.

For reference, the file I install on our devices has the following files;

_setup.xml
00CABB4C.002
0NETCF35.000
GCACUTIL.001
SETUPDLL.999

_setup.xml


<wap-provisioningdoc>
<characteristic type="Install">
<parm name="InstallPhase" value="install" />
<parm name="SetupDLL" value="1" />
<parm name="OSVersionMin" value="4.0" />
<parm name="OSVersionMax" value="6.999" />
<parm name="BuildNumberMin" value="0" />
<parm name="BuildNumberMax" value="-536870912" />
<parm name="UnsupportedPlatforms" value="HPCJUPITERSMARTPHONEPOCKETPC" />
<parm name="AppName" value="Microsoft .NET CF 3.5" />
<parm name="InstallDir" value="%CE2%" translation="install" />
<parm name="NumDirs" value="2" />
<parm name="NumFiles" value="2" />
<parm name="NumRegKeys" value="1" />
<parm name="NumRegVals" value="1" />
<parm name="NumShortcuts" value="0" />
</characteristic>
<characteristic type="FileOperation">
<characteristic type="%CE2%" translation="install">
<characteristic type="MakeDir" />
<characteristic type="cgacutil.exe" translation="install">
<characteristic type="Extract">
<parm name="Source" value="CGACUTIL.001" />
<parm name="NoOverwriteIfNewer" />
<parm name="Shared" />
<parm name="WarnIfSkip" />
</characteristic>
</characteristic>
</characteristic>
<characteristic type="%InstallDir%" translation="install">
<characteristic type="MakeDir" />
<characteristic type="mscoree3_5.dll" translation="install">
<characteristic type="Extract">
<parm name="Source" value="00CABB4C.002" />
<parm name="Shared" />
<parm name="WarnIfSkip" />
</characteristic>
</characteristic>
</characteristic>
</characteristic>
<characteristic type="Registry">
<characteristic type="HKLM\Software\Microsoft\.NETCompactFramework\Installer">
<parm name="GACPath" value="%InstallDir%" datatype="string" translation="install" />
</characteristic>
</characteristic>
</wap-provisioningdoc>


Motorola have an unsupported scripting language called SymScript - ask your reseller or Motorola to provide you with information / files for this.

Using SymScript (or your device's similar scripting model), you can prevent deletion of your CAB files on installation and install them direct from the \Application folder, reducing the time it takes to load the OS after a cold boot.

Our SymScript SPT file is simply placed in the \Application folder

CAB_Install.spt


;
; Description:
; This script will install .NET Framework after cold boot
; after waiting for welcome.exe to complete.
; Can be used for other cab files such as Motorola EMDK
;
SetVar int True = 1
SetVar int False = 0
SetVar int Debug = True

SetVar String AppDir = " \Application\"
SetVar String strScript = GetScriptName( NOEXTENSION )
SetVar String DebugFile = AppDir + strScript + ".Dbg"


; Check for a cold boot, if not a cold boot do nothing
IF ( GetBootCount() > 1 )
GOTO End ;
ENDIF

:WaitForWelcomeToComplete
; Wait for Welcome.EXE to complete
Sleep 1000
IF IsProcessRunning("welcome.exe") == 1
Sleep 1000
GOTO WaitForWelcomeToComplete
ENDIF
:WelcomeDone

;
; Install the CAB file(s)
;
SetVar String Cab1 = AppDir + "NETCF35.cab"

SetVar String CabInstaller = "wceload.exe"

SetFileAttrib Cab1 0x00000001 ; write protect the CAB files to prevent them being deleted

SetVar String strCabInstallOptions = "/noui /delete 0"

SetVar String Cab1 = strCabInstallOptions + Cab1

RUNWAIT CabInstaller Cab1 ; install cab file 1

:END

Comments