Go Back   xda-developers > General discussion > General


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 26th April 2006, 04:31 PM
Menneisyys Menneisyys is offline
Moderator
 
Join Date: Jul 2005
Posts: 5,316
Default Relocate .NET Compact Framework 2.0 to your storage card!

One of the biggest complaints with Microsoft's Compact Framework 2 (CF2 for short) (and, consequently, with programs relying on it - Hitchhiker, SMS Notifier, Webby, IBE Mail etc.) has always been its storage needs, which, by default, is some 5.4 Mbytes. See for example this thread for users' opinions on the memory consumption on CF2 and their subsequent not wanting to install it.

I've always tried to reduce the main memory load on Pocket PC - with great success. Just search for the word-start "relocat" in the Pocket PC Magazine Expert Blog and on my old homepage for some examples of them. No wonder I've also decided to look into this, so far, unsolved problem to greatly help my fellow Pocket PC users. And, after a day's work and testing, I can present you a 100% working solution, which has been thoroughly tested on four of my WM2003+ PDA's, all with success. This IS a big thing, considering that internal memory is still precious, even with most Windows Mobile 5 (WM5) Pocket PC's. (For example, most WM5 PPC's are shipped with 128M of ROM, of which in general 40-45 Mbytes is free.) The situation is even worse with pre-WM5 Pocket PC's, where the available RAM is very rarely (only with devices shipped with 128 Mbytes of RAM) over 50 Mbytes, from which CF2 takes away 5.4 Mbytes.

Note that this will work on all Pocket PC and Pocket PC Phone Edition devices that are able to run CF2 (that is, all WM2003+ devices, including WM5).

The complete tutorial

* create a directory on your storage card or, if you have, in the built-in File Store. (Note that the files, as they are surely not needed at boot time (unlike some Today plug-in DLL's), may also be relocated to a storage card. That is, they don't need to be stored in the more scarce File Store - if it's available at all; that is, if you have a pre-WM5 device). Let's assume you give this directory the name "DLLs".

* move the following files from \Windows to this directory:

cgacutil.exe
MSCOREE2_0.dll
netcfagl2_0.dll
netcfd3dm2_0.dll
GAC_CustomMarshalers_v2_0_0_0_cneutral_1.dll
GAC_Microsoft.VisualBasic_v8_0_0_0_cneutral_1.dll
GAC_Microsoft.WindowsCE.Forms_v2_0_0_0_cneutral_1. dll
GAC_Microsoft.WindowsMobile.DirectX_v2_0_0_0_cneut ral_1.dll
GAC_mscorlib_v2_0_0_0_cneutral_1.dll
GAC_System.Data_v2_0_0_0_cneutral_1.dll
GAC_System.Drawing_v2_0_0_0_cneutral_1.dll
GAC_System.Messaging_v2_0_0_0_cneutral_1.dll
GAC_System.Net.IrDA_v2_0_0_0_cneutral_1.dll
GAC_System.Web.Services_v2_0_0_0_cneutral_1.dll
GAC_System.Windows.Forms.DataGrid_v2_0_0_0_cneutra l_1.dll
GAC_System.Windows.Forms_v2_0_0_0_cneutral_1.dll
GAC_System.Xml_v2_0_0_0_cneutral_1.dll
GAC_System_v2_0_0_0_cneutral_1.dll


(netcf2_0license.txt can also be copied here - or just deleted.)

This means only Microsoft .NET CF 2.0.GAC and mscoree.dll needs to stay in \Windows. Never ever try to touch the former (Microsoft .NET CF 2.0.GAC). Even if you copy it back to \Windows (after starting any CF2-dependent app), CF2 won't work again until you reinstall it.

Copying the files can be done in several ways, of which I show the one way that requires no third-party apps, that is, without having to resort to, for example, the WindowsCE File System plug-in of the desktop-based Total Commander.

Start the built-in (Pocket) File Explorer and navigate to \Windows. Tap and hold an empty (not highlighting any file or directory) region anywhere (for example, the end of the list) and enable "View All files" in the context menu:



Now, click the "Name" drop-down menu in the upper right corner; a "Sort By" list will be displayed, defaulting to "Name". Switch it to "Date":



Scroll to the region with filedates of Aug 26 and, with cgacutil.exe, 27, 2005 (this is the easiest way to find the files) and mass-highlight all files that are listed in the above list. Note that mscoree.dll should not be highlighted (as has been pointed out, it should be left in \Windows). Also note that the filedates of the current, 2.0 version of CF2 are all dated at Aug 26/27 last year. They will only have a different filedate if you've restored them from a backup. Then, they will have the timestamp of the restoration and you'll may end up having to hunting for them one-by-one, based on their name.



Now tap-and-hold the selection somewhere so that the context menu comes up. Choose Cut:



Go to the target directory (in this case, DLLs on your storage card); tap-and-hold an empty area and choose Paste:



The transfer of the files will start:



Note that you can also use other file handler tools on the Pocket PC; for example Resco File Explorer or Total Commander. In Resco, go to File/Options/Browser and make sure "Show all files" is chosen (instead of the default "Hide hidden files and files...") as can be seen in this screenshot.

* get a registry editor that is able to (flawlessly (!)) edit multiline strings (that is, all known, up-to-date registry editors except PHM Registry Editor and Total Commander; please check out The Ultimate Roundup of Registry Editors for the Pocket PC for a thorough explanation of why I don't recommend these two applications if interested). In this tutorial, I use Resco Registry Editor (Resco for short). It's commercial, but the 14-day, unrestricted trial version is fully sufficient for our purposes. Start it.

* First, we'll modify the so-called "System Path" (which is a bit similar to the PATH in traditional operating systems) so that it includes our new directory. To do this, go to HKEY_LOCAL_MACHINE\Loader:



Note that, in here, I've switched to "Tree Mode" in View/Show Tree View as can be seen in here.

Now, click SystemPath (highlighted in this screenshot); you'll be presented the following dialog:



Note that there may be some values already in the text input area in here. For example, if you've ever had SKTools or MemMaid relocate DLL's for you, the target directory will be in here. Also, by default (if you haven't ever touched the System Path), there may be a \Release\ or \windows\oem\ in here. These can be safely deleted as they're not used. You can, naturally, leave them in there; of course, then, you must make sure the new path is entered in a new row as can be seen in this x51v or this HTC Wizard (latest Qtek ROM) screenshot. Once again: you can safely delete them.

All you have to do is entering the full path of your new DLL directory in here. For example, if you've moved the CF2 files to a directory named DLLs on your storage card named CF-Card (Storage Card, CF Card, SD Card, SD-MMCard are also widely used), enter

\CF-Card\DLLs\

in here, as can also be seen in here:



Don't forget to add the leading and the trailing backslash characters (\)!

Now, click OK in the upper right corner and answer Yes:



In the list view, the new, just-entered value should be shown as can be seen in here:



Note that, again, if you want to keep the previous values of System Path, then, the new entry should be put in a separate row. For example, if the previous value of HKEY_LOCAL_MACHINE\Loader has been

\SD-MMCard\Programs\CrEme\bin\
\LOOXstore\DLLs\


then, you need to add the new value in a new row as can be seen in here:



* now comes a bit more complicated part. First, go to HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ .NETCompactFramework\ Installer\ Assemblies\ Global.

Note that, on some devices, in the above path, SOFTWARE may not (all) be uppercase. This varies from model to model and shouldn't be paid attention to. (Also note that I’ve added spaces after every backslash characters (\) in the above registry path so that the blog engine nicely renders it. In the reality, it should not contain any spaces!)

Here, look for names (on the left) that have 2.0 in them. Note that almost all values (except for CustomMarshalers, Microsoft.WindowsMobile.DirectX and Microsoft.WindowsMobile.DirectX, which have all been introduced in CF2 and didn't exist in CF 1.x) seem to be duplicated and their name will start with the same (Microsoft.*, mscorlib.*, System* etc.); it's only after this that they start to be different. One set of them will continue in Version=1.0, the other set will continue in Version=2.0. The only exception from this "must contain Version=2.0" law is the value starting with "Microsoft.VisualBasic, Version=8.0.0.0" (that is, 8.0 instead of 2.0).

In all these Version=2.0 values, you'll need to modify the original path referring to \Windows to the new home of the relocated files - for example, in our case, \CF-Card\DLLs.

In order to be able to see this as easily as possible, enabling Show Header in the View menu is highly recommended, as can be seen in here. Then, you'll be able to greatly increase the displayed length of the value names if you drag the header to the right. Of course, switching to Landscape and/or VGA mode (if possible) is highly recommended. Then, you'll be able to see the version number in all the values. For example, this screenshot shows a QVGA WM5 device in Landscape - here, it's also possible to increase the width of the "Name" column so that the version number can also be seen without having to click every value.

All you need to do is just click all the values that have Version=2.0 in their name (except, as has already been pointed out, the 8.0 Microsoft.VisualBasic) and just change \Windows to the new value in the first row. An example of this:

before:



after:



Another example of a changed value (WM5, QVGA device, with files relocated to \Storage Card\_):



and with the VGA x51v in standard VGA mode:



Note that, much as it refers to the main storage (\Program Files\.NET CF 2.0\), you don't need to pay attention to the second row in all these values. Just leave them there.

Consider using a PC-based Pocket PC controller tool to do this (please read this article for more info on them if not sure). Using them, you can speed up the registry modification by orders of magnitude, particularly if you use copy/paste to insert the new directory path.

After you've modified all the affected values, check once more if it was successful. Fortunately, you'll see all the names (showing that a given value is 2.0-specific) and values (showing whether it refers to the original \Windows directory in the main storage or somewhere else) on the same screen as in this screenshot.

You may also want to export the just-modified branch to a registry (.reg) file. Then, in case you reinstall CF2 and want to avoid hand-editing the entire stuff, you'll only need to reimport this file. To do this, tap-and-hold Globals in the upper, tree pane and choose Export:



On WM5 devices, you will also want to make sure the changes are flushed back to the ROM (as the Registry is kept in RAM and changes are rarely flushed back to ROM, which will result in a simple soft reset getting rid of all changes and, therefore, CF2 not working after the relocation). To do this, on many WM5 devices (like the HTC Wizard), just long-press the Power button. On some other devices, you must explicitly configure the device to shut the PDA completely down upon a long-press (instead of just dimming the screen). For example, on the x51v, you must go to Settings/System/Power/Power Button and enable "Full power off" instead of the default "Dim/light the display" as can be seen in this screenshot. You'll only need to power off your PDA for some seconds because it's before shutting it down that the Registry is flushed back to the ROM; that is, you can safely switch it back on instantly.

Congratulations! Now, the relocated CF2 will be working! If you've modified the System Path, you'll need to reboot; otherwise, you can start your CF2 apps right away.

Advanced remarks for geeks/advanced hackers

* Exporting, editing and re-importing the contents of HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ .NETCompactFramework\ Installer\ Assemblies\ Global (so that you can much easier change all occurrences of \Windows to the new path) just won't work because the values in here are multiline strings, which are exported as hexadecimal values by all export-capable Pocket PC-based registry editors (I've checked this!) like in here:



* The \Windows paths in HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ .NETCompactFramework\ Installer\ Assemblies\ Reference (note that the last word is Reference, not Global!) don't need to be modified. Actually, you can even get rid of the entire subkey because it's not used at all.

* Technically, the GAC*.dll files don't need to be in the System Path; it's only with the other files (cgacutil.exe, MSCOREE2_0.dll, netcfagl2_0.dll and netcfd3dm2_0.dll) that must be. That if, you have already set up a relocated DLL directory somewhere in the System Path, you can safely move the files to there. It's in order to be as easy as possible for a novice user that I've instructed copying all relocated files to the same directory in the System Path.
__________________
Microsoft MVP - Mobile Devices, 2006, 2007, 2008. Make sure you follow my PPC & SP Mag Expert blog HERE.
Reply With Quote
Sponsored Links

  #2  
Old 26th April 2006, 04:53 PM
Rudegar's Avatar
Rudegar Rudegar is offline
Moderator
 
Join Date: Jul 2003
Location: DK
Posts: 12,092
Default

one better make damm sure that one dont have any .net programs running when the pda is off too
because then the SD interface get shutdown to save power
and then programs which are running which depend on the framework crash and burn
__________________
hhhmm ok i may be a jerk but i'm a jedi jerk like my father was before me
BTW "I can't use a skeleton arm with that"
Reply With Quote

  #3  
Old 26th April 2006, 05:00 PM
Menneisyys Menneisyys is offline
Moderator
 
Join Date: Jul 2005
Posts: 5,316
Default

Quote:
Originally Posted by Rudegar
one better make damm sure that one dont have any .net programs running when the pda is off too
because then the SD interface get shutdown to save power
and then programs which are running which depend on the framework crash and burn
Yup, but you can also play with PNPUnloadDelay to avoid problems because of this (see http://www.pocketpcthoughts.com/foru...ic.php?t=44488 for more info).
__________________
Microsoft MVP - Mobile Devices, 2006, 2007, 2008. Make sure you follow my PPC & SP Mag Expert blog HERE.
Reply With Quote

  #4  
Old 26th April 2006, 06:51 PM
jeffreii jeffreii is offline
Member
 
Join Date: Nov 2005
Location: Miami, FL
Posts: 51
Default

how does this method compare to the way the new beta allows GAC to be installed to the storage card?

http://www.microsoft.com/downloads/d...displaylang=en

from what another user told me, the beta allows you to install about 80% of the framework to the storage card.

-jeff
Reply With Quote

  #5  
Old 27th April 2006, 04:04 PM
dborello dborello is offline
Member
 
Join Date: Mar 2004
Posts: 53
Default

Quote:
Originally Posted by jeffreii
how does this method compare to the way the new beta allows GAC to be installed to the storage card?

http://www.microsoft.com/downloads/d...displaylang=en

from what another user told me, the beta allows you to install about 80% of the framework to the storage card.

-jeff
Yes !!! Thanks for the council.
Before with the previous version of net framework 2 my free memory was of 25,80 Mb.
After to have installed the Sp1 new beta on the Storage Card is of 29,78 Mb.
__________________
HTC Blackstone 1.14 ITA no brand
Reply With Quote

  #6  
Old 28th October 2006, 02:56 PM
craigiecraigie4 craigiecraigie4 is offline
Senior Member
 
Join Date: Oct 2005
Posts: 354
Default

Hi Menneisyys. Would MUCH appreciate your guidance;
I'm using a ROM image that works great - except that the CF 2.0 SP1 installation is buggy. I can't de-install it as it's not in my installed apps. Any idea what files I need to delete so the install proggie thinks it's gone and does a reasonable re-install? Currently the install proggie says "you already have this verison installed".
__________________
  1. Alpine (iMate PDA2 - great at the time)
  2. Magician (iMate JAM - great at the time)
  3. Wizard (iMate KJam - disasterous)
  4. Universal WM5 AKU3.5 (iMate JasJar - complete crap)
  5. Hermes WM6 Black Majik (HTC TyTn - best yet despite QVGA)
  6. Elf WM6 Blue Touch ROM (Finally I'm delighted!!!)
  7. Diamond (hmm, just a touch with VGA, GPS & 3G + pretty unusable TouchFlo3D)
Reply With Quote

  #7  
Old 28th October 2006, 06:49 PM
Menneisyys Menneisyys is offline
Moderator
 
Join Date: Jul 2005
Posts: 5,316
Default

Quote:
Originally Posted by craigiecraigie4 View Post
Hi Menneisyys. Would MUCH appreciate your guidance;
I'm using a ROM image that works great - except that the CF 2.0 SP1 installation is buggy. I can't de-install it as it's not in my installed apps. Any idea what files I need to delete so the install proggie thinks it's gone and does a reasonable re-install? Currently the install proggie says "you already have this verison installed".

Unfortunately, it's not only files but also registry entries. Try deleting all the above-listed, 2.0-only (don't touch the CF1-specific ones!) registry entries.

Do you have WM5 or a previous OS? If you have the latter, I can send over an .unload file and a registry import so that you can directly delete these without any manual registry editing.
__________________
Microsoft MVP - Mobile Devices, 2006, 2007, 2008. Make sure you follow my PPC & SP Mag Expert blog HERE.
Reply With Quote

  #8  
Old 29th October 2006, 06:19 AM
craigiecraigie4 craigiecraigie4 is offline
Senior Member
 
Join Date: Oct 2005
Posts: 354
Default

Quote:
Originally Posted by Menneisyys View Post
Unfortunately, it's not only files but also registry entries. Try deleting all the above-listed, 2.0-only (don't touch the CF1-specific ones!) registry entries.

Do you have WM5 or a previous OS? If you have the latter, I can send over an .unload file and a registry import so that you can directly delete these without any manual registry editing.
Hi Mennei, I'm on WM5 and would TRLUY appreciate a .unload file! Thanks a stack.
__________________
  1. Alpine (iMate PDA2 - great at the time)
  2. Magician (iMate JAM - great at the time)
  3. Wizard (iMate KJam - disasterous)
  4. Universal WM5 AKU3.5 (iMate JasJar - complete crap)
  5. Hermes WM6 Black Majik (HTC TyTn - best yet despite QVGA)
  6. Elf WM6 Blue Touch ROM (Finally I'm delighted!!!)
  7. Diamond (hmm, just a touch with VGA, GPS & 3G + pretty unusable TouchFlo3D)
Reply With Quote

  #9  
Old 29th October 2006, 07:33 AM
Menneisyys Menneisyys is offline
Moderator
 
Join Date: Jul 2005
Posts: 5,316
Default

Quote:
Originally Posted by craigiecraigie4 View Post
Hi Mennei, I'm on WM5 and would TRLUY appreciate a .unload file! Thanks a stack.
Unfortunately, you can't easily hack WM5 (as opposed to pre-WM5 OS'es) to think it has a program installed - you don't have write rights on \Windows\AppMgr and, tehrefore, can't copy the (un)install DLL there. That is, with WM5, it's, to my knowledge, not possible to automatically remove stuff.
__________________
Microsoft MVP - Mobile Devices, 2006, 2007, 2008. Make sure you follow my PPC & SP Mag Expert blog HERE.
Reply With Quote

  #10  
Old 29th October 2006, 09:38 AM
blazoner's Avatar
blazoner blazoner is offline
Senior Member
 
Join Date: Oct 2006
Location: Jacksonville, FL
Posts: 141
Question

Quote:
Originally Posted by Menneisyys View Post
Unfortunately, you can't easily hack WM5 (as opposed to pre-WM5 OS'es) to think it has a program installed - you don't have write rights on \Windows\AppMgr and, tehrefore, can't copy the (un)install DLL there. That is, with WM5, it's, to my knowledge, not possible to automatically remove stuff.
hmmm.....
maybe if you installed a "dummy" program that would reference the appropriate uninstall file for CF2.0?

just an uneducated noob suggestion. (feel free to educate me! i'm always eager to learn)
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:40 AM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.