[對於PDA手持程序從工程的新建、環境配置、調試及其錯誤處理盡量提供一些解決方案,如果沒有你想要的答案,也希望能提供一些有益的思路,你在開發中遇到的問題及解決方案懇請你在此與大家分享共同學習,使這些內容更加完善]
開發環境
Visual Studo 2008(.NET Framework 3.5)
第一步:新建工程
1、文件 -> 新建 -> 項目 或快捷鍵(Ctrl + Shift + N)

圖(1)
2、目標平台選擇“Pocket PC 2003”默認“Windows Mobile 5.0 Pocket PC SDK”
.NET Compact Framework 版本©:根據自己當前使用版本而定,VS08支持2.0和3.5

圖(2)
PS:平台Pocket PC 2003只支持.NET 2.0,
即
平台Pocet PC 2003只支持.NET 2.0,
平台Windows Mobile 5.0 Pocket PC SDK支持.NET 2.0與.NET 3.5

圖(3)
至此工程搭建完畢,下面進行調試環境搭建及調試
第二部:開啟設備仿真管理器並進行網絡設置
1、工具 –> 設備仿真器管理器

圖(4)
2、右鍵選擇“CHS Windows Mobile 5.0 Pocket PC R2 Emulator” –> 連接(此時電腦右下角會出現模擬器圖表)

圖(5)
3、右鍵選擇“CHS Windows Mobile 5.0 Pocket PC R2 Emulator” –> 插入底座

圖(6)
4、網絡設置
圖(7):開始 -> 設置
圖(8):設置 –> 連接(默認個人)頁 -> 連接
圖(9):連接 -> 高級(默認)任務頁 -> 選擇網絡
圖(10):選擇網絡 -> 網絡管理(如圖選項設置)
| 圖(7) 開始 -> 設置 |
圖(8) 設置 –> 連接(默認個人)頁 -> 連接 |
|
圖(9) 連接 -> 高級(默認)任務頁 -> 選擇網絡 |
圖(10) 選擇網絡 -> 網絡管理(如圖選項設置) |
第三部:安裝模擬器插件及設置(與設備仿真管理器進行連接設置)
1、安裝模擬器插件
(安裝:右鍵選中 –> 包”對象” -> 激活內容)
2、連接設置

圖(11)
剛開始會自動進行連接,如果是初次使用會連接失敗,這時需要手動進行連接,如圖

圖(12)
點擊“連接”按鈕進行連接

圖(13)
如圖所示標識模擬器已與設備仿真管理器已同步

圖(14)
連接過程總如出現下圖情況,請檢查設備仿真器是打開(步驟二操作)

圖(15)
第四部:利用VS進行調試,右鍵項目 –> 調試 -> 啟動新實例

圖(16)
| 圖(17)部署中 |
圖(18)測試通過 |
測試通過!源碼附上
View Code
1 using System;
2 using System.Linq;
3 using System.Collections.Generic;
4 using System.ComponentModel;
5 using System.Data;
6 using System.Drawing;
7 using System.Text;
8 using System.Windows.Forms;
9
10 namespace PDAExample
11 {
12 /// <summary>
13 /// 登錄
14 /// @Author cluo
15 /// @Date 2011-12-23
16 /// </summary>
17 public partial class FrmLogin : Form
18 {
19 public FrmLogin()
20 {
21 InitializeComponent();
22 }
23
24 // 輸入驗證
25 private bool ValidateInput()
26 {
27 if (string.IsNullOrEmpty(txtLoginID.Text.Trim()))
28 {
29 MessageBox.Show("請輸入用戶名");
30 txtLoginID.SelectAll();
31 txtLoginID.Focus();
32 return false;
33 }
34 else if (string.IsNullOrEmpty(txtLoginPwd.Text.Trim()))
35 {
36 MessageBox.Show("請輸入密碼");
37 txtLoginPwd.SelectAll();
38 txtLoginPwd.Focus();
39 return false;
40 }
41 return true;
42 }
43
44 // 用戶名校驗
45 private void txtLoginID_KeyPress(object sender, KeyPressEventArgs e)
46 {
47 if (e.KeyChar != 13) return;
48 ValidateInput();
49 }
50
51 // 密碼校驗
52 private void txtLoginPwd_KeyPress(object sender, KeyPressEventArgs e)
53 {
54 if (e.KeyChar != 13) return;
55 if (ValidateInput()) btnLogin_Click(null, null);
56 }
57
58 // 登錄
59 private void btnLogin_Click(object sender, EventArgs e)
60 {
61 if (ValidateInput())
62 {
63 MessageBox.Show("登錄成功");
64 }
65 }
66
67 // 取消
68 private void btnCancel_Click(object sender, EventArgs e)
69 {
70 Application.Exit();
71 }
72 }
73 }
啟動調試報錯處理:
錯誤 1 部署和/或注冊失敗,錯誤為: 0x8973190e。 寫入文件“\Windows\NETCFv35.ppc.armv4.cab”時出錯。錯誤 0x80070070: 磁盤空間不足。
Device Connectivity Component
解決方案:
目標平台不支持.NET版本,即低目標平台不支持高.NET版本,例如 Pocket PC 2003則不支持.NET 3.5,反之則兼容,Windos Mobile 5.0 Pocket PC SDK則兼容.NET 2.0和.NET 3.5版本,所以在新建工程時目標平台和.NET版本如果不兼容的話則會出現如上錯誤。







