free web page counters

Windows Mobile Pocket PC Smartphone Programming

==>Click here for the SiteMap<==. Original contents with decent amount of source codes.

Monday, November 28, 2005

Error: cab file could not be created - No, not again! Nice workaround/solution

====>SiteMap of this Blog<===

Error: cab file could not be created - No, not again! Ultimate workaround/solution

How many times did you see the dreaded message "Error: CAB file 'XXX.CAB' could not be created", after you managed to tackle the compilation error, managed to build the needed DLLs, EXEs, and managed to write a good CAB .inf file? Worse, the error file that CabWiz is supposed to dump error message is empty! This left you cluelessly scratching your head, having no idea what exactly you did wrong.

I have seen so many such errors in my development, and I do not think I did anything wrong. Why? Here is my story posted to Microsoft MSDN forum. Sometimes the new CabWiz (shipped with VS2005) worked, sometimes did not. Sometimes the old CabWiz (shipped with PPC2003 SDK) worked, sometime did not. Sometimes everything worked in my PC, but not in my teammate's...

With the incredible tool from the wizards in sysinternals, I monitored the file-system activities after launching CabWiz. Looks like CabWiz first analyzed the .INF file, generated an intermediate file based on a template (cabwiz.ddf), then asked makecab.exe to build the CAB based on the intermediate file. Makecab failed at the stage when a CAB was being created, for no apparent reason. That explained why CabWiz could not report any meaningful error message, because makecab.exe did not communicate with CabWiz why it failed.

Finally I figured out probably the buggy tool is not comfortable with the long fully-qualified CAB filename. So I did a subst, making sure the current directory for CabWiz is very short. Viola! It works. So the ultimate solution is to use Subst to shorten the absolute name of your CAB file, and launch CabWiz from that shorten path.

Example:

Original path of INF file

c:\MyWork\WindowsMobile\superlong1\superlogn2\superlong3 superlogn4\superlogn5\superlogn6\superlogn7 MailClient\src\Shared\MailClient_release.PPC2003_en.inf

Do a subst:

Subst v: c:\MyWork\WindowsMobile\superlong1\superlogn2\superlong3 superlogn4\superlogn5\superlogn6\superlogn7

Then file Cabsize in V: rather than in C:

Sometimes even if the original path is not very long (like 120 characters), CabWiz still fails. A subst is still a good solution.

PS: Microsoft's documentation on Subst. Or you can type "subst /h" on the command line to see the details how it works.

Category: [Cabwiz / Build]

====>SiteMap of this Blog<===