用于检测 .NET CF 3.5 并安装的 Windows Mobile Cab 安装程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1119255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows Mobile Cab Setup to detect .NET CF 3.5 and Install It
提问by sw_engineer
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++.
我已经使用目标框架作为 .NET CF 3.5 和专业 6 SDK 开发了 windows mobile 6 专业应用程序。还创建了它的 SmartDeviceCab 文件。当我在没有 CF 3.5 的设备上安装它时,它无法运行我的应用程序(因为该设备有 .NET CF 2.0)。现在我知道我必须在要运行我的应用程序的设备上安装 NET CF 3.5。如何检测当前版本的 CF 并从我的 cab 设置中安装(如果需要)CF 3.5。我已经对 Setup.dll 进行了很多探索和研究,但它的方法太老了,我没有找到从我的 Setup.dll 运行 cab 文件的方法。请帮我找到解决方案。如果提供链接/示例代码,将不胜感激。更令人沮丧的是,我从来没有接触过VC++。
I have gone through: Detecting if the Compact Framewok is installed on mobile deviceand its links.
我已经完成了: 检测 Compact Framewok 是否安装在移动设备及其链接上。
Shailesh K.
沙利什K。
回答by Dylan Vester
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++ 代码,但您根本不必更改它。只需创建包含要安装的 .NET cab 文件的第二个智能设备 cab 项目(在您的情况下为 3.5),并将安装 DLL 交换为从示例中包含的 C++ 项目创建的安装 DLL。您只需添加描述要安装的 cab 文件的位置的注册表值,您就可以使用了。您不需要检测他们安装了哪个版本的 .NET,只需将它放在那里,它就会安装在任何现有安装的顶部。示例中有完整的白皮书以及源代码对其进行了解释。只需下载 Windows Mobile 6 SDK 并在安装后导航到您计算机上的此目录。打开标题为“MultiCab Whitepaper.doc”的文档
C:\Program Files\Windows Mobile 6 SDK\Samples\Common\CPP\Win32\multicabinstall
C:\Program Files\Windows Mobile 6 SDK\Samples\Common\CPP\Win32\multicabinstall
I used this for my own project and it works SO well!
我在我自己的项目中使用了它,效果很好!
回答by sw_engineer
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. :)
现在 Windows Market Place 就在那里,所以我们不需要关心所需的 .NET CF 版本。Windows Market Place 将完成所需的工作。:)
回答by Jeff Pigott
We have used AirSetup for this as it lets you chain installs and works really well and fast.
我们为此使用了 AirSetup,因为它可以让您进行链式安装并且运行得非常好且快速。
http://windowsmobiledn.com/using-spb-airsetup-to-create-pocket-pc-installers/
http://windowsmobiledn.com/using-spb-airsetup-to-create-pocket-pc-installers/
回答by ageektrapped
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.
我相信在 WM 6 中(可能是 WM 5),他们不允许从另一个驾驶室中运行驾驶室。一次性完成所有操作的唯一方法是通过桌面上的 MSI。有关于如何开始的 MSDN 示例。
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.
我在我的应用程序中所做的是在我的驾驶室中检测 .NET CF 版本。如果他们没有正确的安装,我将无法安装并告诉用户从桌面安装。这不是最好的解决方案,但 MS 并没有真正给我们选择。
回答by MusiGenesis
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.
这并不是您问题的真正答案,但在这种情况下,我只会部署两个 CAB:我的应用程序和 .Net CF 3.5 CAB。告诉客户/客户安装您的应用程序并不难,如果它不起作用,则安装 .Net cab。
回答by sw_engineer
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?
感谢您的回复。令人失望的是,MS 对此没有直接的解决方案。我现在会选择 MusicGenesis。我可以给用户两个出租车 (1) MyApp.cab (2) NETCFv35.wm.armv4i.cab。但我想知道“NETCFv35.wm.armv4i.cab”适用于所有设备。我听说过具有不同指令集(如 MISP、ARM 等)的不同设备。NETCFv35.wm.armv4i.cab 是否适用于所有 Windows Mobile 6 Professional(以及更高版本 6.1、6.5),或者我必须如何处理其他设备?
Shailesh K
沙利什K
回答by mkmurray
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.
您是否使用过任何特定于 .NET 3.5 的 API 会阻止您面向 .NET 2.0 Framework?如果没有(或者它很少),我会考虑只针对 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.
您可能会惊讶于更改目标框架的版本是多么容易(不幸的是,您不能像使用 Visual Studio 中的其他项目类型那样直接在解决方案资源管理器中转到项目节点的属性)。我建议针对 2.0 框架创建一个新项目,并将所有源代码放入,编译,然后查看有多少错误。希望在大约 5 到 10 分钟内,您完成编译并运行的应用程序,不再有 .NET Framework 依赖项问题。
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.
在规划我希望编写的移动应用程序时,我选择坚持使用 .NET 2.0,因为默认情况下,很多设备不附带 3.5。
回答by chocojosh
For this I used NSIS. It's been a few months since I wrote the install script, so some details should be fuzzy.
为此,我使用了 NSIS。我写安装脚本已经几个月了,所以一些细节应该是模糊的。
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.
首先我安装 .NET CF 3.5。我使用文件 NETCFSetupv35.msi,如果它不存在,它会自动在移动设备上安装 .NET CF 3.5。如果 .NET CF 3.5 已经存在,它会显示一个对话框,说明它已经存在(对我们来说这是可以接受的)。您可以找到/编写一个应用程序,该应用程序将设置可由 ExecWait ( http://nsis.sourceforge.net/Docs/Chapter4.html)读取的返回值,然后仅在未安装 .NET CF 时调用 msi .
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.
然后我要安装 8 个 cab,3 个用于 SQL Server Compact 3.5(必需),4 个用于我们依赖的软件(可选,取决于客户端),1 个用于我们的应用程序。我遵循了本教程:http: //nsis.sourceforge.net/NSIS_for_Smartphone。为每个写一个部分,如果您想要只读,则在该部分后添加 SectionIn 1 RO。然后调用 CeAppMgr 作为参数传递给每个 CAB。

