Notices

Tips and Tricks Share tips that can save others time and frustration here !

Reply
 
LinkBack Thread Tools
Old 04-26-06, 10:18 AM   #1 (permalink)
Contributing Reviewer
 
Join Date: Jan 2005
Posts: 4,582
Thanked 1 Time in 1 Post
Relocate .NET Compact Framework 2.0 to your storage card: free up 5.4 Mbytes memory!!

UPDATE (06/24/2006): this article is deprecated. Now that the final version of CF2 SP1 is out (see this blog post), it's not worth any more struggling with the pre-SP1 CF2. SP1 can already be installed to alternative targets. Please see the above blog post on acquiring CF2 SP1.

I, however, keep the original article in here for historic reasons. It is as follows:






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.
__________________
MS MVP- Mobile Devices.

Last edited by Menneisyys; 06-24-06 at 04:04 AM.
Menneisyys is offline   Reply With Quote
Sponsor Ads
Old 04-26-06, 03:00 PM   #2 (permalink)
Empel1960
Guest
 
Posts: n/a

Cool, thanks for sharing, just made the relocation.....:approve:
  Reply With Quote
Old 04-26-06, 05:47 PM   #3 (permalink)
Aximsite Elite
 
Rishad's Avatar
 
Join Date: Aug 2005
Location: Vancouver, BC
Posts: 3,677
Device: iPhone 2G (OS 3.1)
Carrier: City Fido
Thanked 1 Time in 1 Post

Awards Showcase
Aximsite Active Bronze Member Admin Medal Aximsite Contest Winner Top Notch MyPDA Red Cross 
Total Awards: 5

Great tutorial! I'll surely be using this if I choose to upgrade to v2.0 from v1.0 SP3.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

.
.
.
.
.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.




To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Rishad is offline   Reply With Quote
Old 04-26-06, 07:34 PM   #4 (permalink)
Aximsite All Star
 
EngrPaul's Avatar
 
Join Date: Aug 2005
Location: Pennsylvania
Posts: 877
Thanked 2 Times in 2 Posts
Fantastic!

You're an asset to the community... thanks for 1,000 great posts....
__________________
"I'm a perfectionist, but not very good at it yet."
EngrPaul is offline   Reply With Quote
Old 04-27-06, 10:53 AM   #5 (permalink)
mv-clear
Guest
 
Posts: n/a
This works great, the PDA works sooo much faster now....
  Reply With Quote
Old 04-27-06, 10:56 AM   #6 (permalink)
Aximsite Minor League
 
Knumb's Avatar
 
Join Date: Mar 2006
Location: California
Posts: 129
Device: Fuze
Carrier: AT&T
Thanked 0 Times in 0 Posts
SWEET!!! I will definitely have to do this...thanks for the great tut!
__________________
KNUMB
Knumb is offline   Reply With Quote
Old 04-27-06, 03:07 PM   #7 (permalink)
m0m0
Guest
 
Posts: n/a
Give that man a gold star!

Excellent idea, excellent tutorial!

Was just trying to find a way to clean up some internal memory when I stumbled across this post. Worked like a charm. Only app I have (I think) that requires CF Net 2.0 is HitchHiker, and it's still functioning after the move.

Thanks!
  Reply With Quote
Old 04-28-06, 03:08 AM   #8 (permalink)
Aximsite Minor League
 
rsmith451's Avatar
 
Join Date: Mar 2006
Location: A mudball called Earth.
Posts: 105
Thanked 0 Times in 0 Posts
Cool beans!

But I saw a lot more GAC files than just the ones listed. Like
GAC_Microsoft.VisualBasic_v7_0_5000_0_cneutral_1.d ll
GAC_Microsoft.WindowsCE.Forms_v1_0_5000_0_cneutral _1.dll
GAC_Microsoft.WindowsMobile.Configuration_v1_0_0_0 _cneutral_1.dll
and others.
Can these not be moved? Or, do they have to be moved if we change the reg entries? Also, cgautil.exe really didn't want to be moved. I got a message saying it can't move things in Rom. Hmmm.

x51v, WM5.
rsmith451 is offline   Reply With Quote
Old 04-28-06, 03:44 AM   #9 (permalink)
Contributing Reviewer
 
Join Date: Jan 2005
Posts: 4,582
Thanked 1 Time in 1 Post
Originally Posted by rsmith451
Cool beans!

But I saw a lot more GAC files than just the ones listed. Like
GAC_Microsoft.VisualBasic_v7_0_5000_0_cneutral_1.d ll
GAC_Microsoft.WindowsCE.Forms_v1_0_5000_0_cneutral _1.dll
GAC_Microsoft.WindowsMobile.Configuration_v1_0_0_0 _cneutral_1.dll
and others.
Can these not be moved? Or, do they have to be moved if we change the reg entries? Also, cgautil.exe really didn't want to be moved. I got a message saying it can't move things in Rom. Hmmm.

x51v, WM5.

They're all part of CF 1.0, in ROM (that is, they don't take up any valuable built-in storage) and come with the device. That is, no attention needs to be paid to them.

If you can't move cgautil.exe, it's not a big problem because it's some 20-30kbytes only - that is, more than two orders of magnitude less than the total relocation saving.
__________________
MS MVP- Mobile Devices.
Menneisyys is offline   Reply With Quote
Old 04-28-06, 07:25 AM   #10 (permalink)
Aximsite Minor League
 
rsmith451's Avatar
 
Join Date: Mar 2006
Location: A mudball called Earth.
Posts: 105
Thanked 0 Times in 0 Posts
OK, seems to work great! Hitchhiker still works after the relocation.
Now I want more!
:)

Last edited by rsmith451; 04-28-06 at 07:33 AM.
rsmith451 is offline   Reply With Quote
Old 04-28-06, 09:10 AM   #11 (permalink)
Contributing Reviewer
 
Join Date: Jan 2005
Posts: 4,582
Thanked 1 Time in 1 Post
Originally Posted by rsmith451
OK, seems to work great! Hitchhiker still works after the relocation.
Great!

Originally Posted by rsmith451
Now I want more!
:)
If you run into stuff that installs itself (or, at least, a lot of DLL's and stuff) into the main storage, let me know and, when I have some time, I'll look at it too - just like with my previous relocation projects.
__________________
MS MVP- Mobile Devices.
Menneisyys is offline   Reply With Quote
Old 04-28-06, 10:50 AM   #12 (permalink)
Aximsite All Star
 
Join Date: Dec 2004
Posts: 982
Thanked 0 Times in 0 Posts

Awards Showcase
Aximsite Active Bronze Member Aximsite Contest Winner 
Total Awards: 2

Wow, this would be a great tweak to be included in Tweak2k2. Hint! Hint!
jimbo32 is offline   Reply With Quote
Old 04-28-06, 01:11 PM   #13 (permalink)
Aximsite Hall of Fame
 
stevenator65's Avatar
 
Join Date: Apr 2005
Posts: 6,324
Thanked 0 Times in 0 Posts
I'm not one to generally hack a registry, but after I started the first step I just kept going. The instructions were excellent. The only feedback I would give is that I uninstalled wififofum, the program I originally installed that caused me to install .net2, so I had no way to test if I moved everything correctly. However, after I moved everything, my pocket pc seems to work just fine and I have more free space, so I'm quite thrilled! Thanks, Menneisyys!
stevenator65 is offline   Reply With Quote
Old 04-28-06, 02:10 PM   #14 (permalink)
AtTheCross
Guest
 
Posts: n/a
I only gained about 3.5M (which I'm very happy with!) Just wondering why I didn't see the 5.4M gain?
  Reply With Quote
Old 04-28-06, 03:34 PM   #15 (permalink)
Contributing Reviewer
 
Join Date: Jan 2005
Posts: 4,582
Thanked 1 Time in 1 Post
Originally Posted by AtTheCross
I only gained about 3.5M (which I'm very happy with!) Just wondering why I didn't see the 5.4M gain?
Some DLL's were copied only and not moved - that is, they remained in the main memory. The reason for this is that they were locked when you tried to move them - a CF2-dependent app ran then.

Look into \Windows to see what DLL's there are.
__________________
MS MVP- Mobile Devices.
Menneisyys is offline   Reply With Quote
Reply

Tags
card, compact, framework, free, mbytes, memory, net, relocate, storage

Sponsor Ads

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free up your memory and optimize your Internet access speed-relocate the PIE/NF cache Menneisyys Tips and Tricks 2 09-12-05 04:37 PM
Is it possible to relocate Conduits Peacemaker from the main memory? Menneisyys Tips and Tricks 0 09-07-05 03:23 PM
Relocating connect2internet Pro 3.x from the main memory – free up over 2 Mbytes! Menneisyys Tips and Tricks 0 08-25-05 06:12 AM
NET Compact Framework 1.0 SP3 from BIS sdsi X30 / X3 / X3i Forums 0 08-16-05 10:00 AM
.Net Compact Framework Oxybeles X30 / X3 / X3i Forums 9 09-04-04 12:58 AM


All times are GMT -5. The time now is 10:29 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2003-10 LeckMedia, LLC