简体   繁体   中英

Windows Mobile Cab Setup to detect .NET CF 3.5 and Install It

I have developed windows mobile 6 professional application using targeted framework as .NET CF 3.5 and professional 6 SDK. Also created its SmartDeviceCab file. When I install it on device not having CF 3.5 it fails to run my application (because the device has .NET CF 2.0). Now I know that I must have NET CF 3.5 on the device where I want to run my app. How can I detect the current version of CF and install(if required) CF 3.5 from my cab setup. I have explored and gone through much on Setup.dll but its too old way and I didn't find way to run cab file from my Setup.dll. Please help me to find the solution. Would be grateful if link/sample code provided. More frustrating is, I never touched VC++.

I have gone through: Detecting if the Compact Framewok is installed on mobile device and its links.

Shailesh K.

Very simple. It has a little C++ code, but you don't have to change it at all. It's simply a matter of creating a second smart device cab project containing the .NET cab file you want to install (3.5 in your case), and swapping the installation DLL for the one created from the C++ project included in the sample. You just add registry values that describe where the cab files you want to install are and you're golden. You don't need to detect what version of .NET they have installed, just throw it in there and it will install over the top of any existing installation. There is a full whitepaper that explains it in the sample, as well as source code. Just download the Windows Mobile 6 SDK and navigate to this directory on your computer after installing it. Open the document titled "MultiCab Whitepaper.doc" and follow the instructions.

C:\\Program Files\\Windows Mobile 6 SDK\\Samples\\Common\\CPP\\Win32\\multicabinstall

I used this for my own project and it works SO well!

In WM 6, I believe (it could have been WM 5), they disallowed running a cab from within another cab. The only way to do it all in one go is through an MSI from the desktop. There are MSDN samples on how to get that started.

What I do in my app is detect the .NET CF version in my cab. If they don't have the right one, I fail the install and tell the user to install from the desktop. It's not the greatest solution, but MS doesn't really give us a choice.

This is not really an answer to your question, but in a situation like this I would just deploy two CABs: my application and the .Net CF 3.5 CAB. It's not that hard to tell a customer/client to install your app, and if it doesn't work to then install the .Net cab.

Now Windows Market Place is there, so we don't need to take care about required .NET CF versions. Windows Market Place will do the required. :)

We have used AirSetup for this as it lets you chain installs and works really well and fast.

http://windowsmobiledn.com/using-spb-airsetup-to-create-pocket-pc-installers/

Thanks for replies. Its really disappointing that MS has no straightforward solution for this. I would go with MusicGenesis for now. I can give user two cabs (1) MyApp.cab (2) NETCFv35.wm.armv4i.cab. But I wanted to know that "NETCFv35.wm.armv4i.cab" will work for all devices. I heard about different devices with different instruction sets like MISP, ARM etc. Will NETCFv35.wm.armv4i.cab work for all Windows Mobile 6 Professional (and higher 6.1, 6.5) or what I have to do to take care of other devices?

Shailesh K

Have you used any .NET 3.5-specific API's that would prevent you from targeting .NET 2.0 Framework? If not (or if it is very little), I would consider just targeting 2.0.

You may be surprised how easy it is to change the version of the Framework you are targeting (unfortunately you can't just go to the Properties of your Project node in the Solution Explorer like you can with other project types in Visual Studio). I would suggest making a new project targeting the 2.0 Framework and dropping all of your source code in, compile, and see how many errors you have. The hope is that in about 5-10 mins, you are done with a compiled and running app, with no more .NET Framework dependency issues.

In planning a mobile app that I hope to write, I have chosen to stick with .NET 2.0 because so many devices don't ship with 3.5 by default.

For this I used NSIS. It's been a few months since I wrote the install script, so some details should be fuzzy.

First I install .NET CF 3.5. I use the file NETCFSetupv35.msi which automatically will install the .NET CF 3.5 on the mobile device if it doesn't already exist. If .NET CF 3.5 already exists, it shows a dialog box saying it already exists (for us this was acceptable). You could find/write an application that would set a return value that can be read by ExecWait ( http://nsis.sourceforge.net/Docs/Chapter4.html ), and then only call the msi if .NET CF is not installed.

Then I have 8 cabs to install, 3 for SQL Server Compact 3.5 (required), and 4 for a software that we depend on (optional, depending on client), and 1 for our app. I followed this tutorial: http://nsis.sourceforge.net/NSIS_for_Smartphone . Wrote a section for each one, if you want readonly then add SectionIn 1 RO after the section. Then call CeAppMgr passing as argument each CAB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM