How to: Include a Data File in a ClickOnce Application

本文介绍如何在ClickOnce应用程序中包含各种类型的数据文件,包括使用Mage.exe和MageUI.exe两种方法。通过更新应用程序清单并重新签名部署清单,确保数据文件正确集成。
 
How to: Include a Data File in a ClickOnce Application

Each ClickOnce application you install is assigned a data directory on the destination computer's local disk where the application can manage its own data. Data files can include files of any type: text files, XML files, or even Microsoft Access database (.mdb) files. The following procedures show you how to add a data file of any type into your ClickOnce application.

To include a data file by using Mage.exe

  1. Add the data file to your application directory with the rest of your application's files.

    Typically, your application directory will be a directory labeled with the deployment's current version—for example, v1.0.0.0.

  2. Update your application manifest to list the data file.

    mage -u v1.0.0.0/Application.manifest -FromDirectory v1.0.0.0

    Performing this task re-creates the list of files in your application manifest and also automatically generates the hash signatures.

  3. Open the application manifest in your preferred text or XML editor and find the file element for your recently added file.

    If you added an XML file named Data.xml, the file will look similar to the following code example.

<file name="Data.xml" hash="23454C18A2DC1D23E5B391FEE299B1F235067C59" hashalg="SHA1" asmv2:size="39500" />

  1. Add the attribute type to this element, and supply it with a value of data.

<file name="Data.xml" writeableType="applicationData" hash="23454C18A2DC1D23E5B391FEE299B1F235067C59" hashalg="SHA1" asmv2:size="39500" />

  1. Re-sign your application manifest by using your key pair or certificate, and then re-sign your deployment manifest.

    You must re-sign your deployment manifest because its hash of the application manifest has changed.

    mage -s app manifest -cf cert_file -pwd password

    mage -u deployment manifest -appm app manifest

    mage -s deployment manifest -cf certfile -pwd password

To include a data file by using MageUI.exe

  1. Add the data file to your application directory with the rest of your application's files.

  2. Typically, your application directory will be a directory labeled with the deployment's current version—for example, v1.0.0.0.

  3. On the File menu, click Open to open your application manifest.

  4. Select the Files tab.

  5. In the text box at the top of the tab, enter the directory that contains your application's files, and then click Populate.

    Your data file will appear in the grid.

  6. Set the File Type value of the data file to Data.

  7. Save the application manifest, and then re-sign the file.

    MageUI.exe will prompt you to re-sign the file.

  8. Re-sign your deployment manifest

    You must re-sign your deployment manifest because its hash of the application manifest has changed.

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值