簡體   English   中英

WinCe 6上的Windows窗體應用程序

[英]Windows Form application on WinCe 6

我正在構建一個簡單的Windows窗體應用程序。

它非常簡單,在我的Windows PC上運行沒有任何問題。

如果我嘗試在我的Windows Ce設備上復制.exe和.pdb文件並嘗試啟動它,我會收到此錯誤:

File or assembly name
'System.windows.forms, Version= 2.0.0.0, Culture=neutral, PublickKeyToke= ..... or one of its dependecies, was not found.

我的應用程序有兩個簡單的文本框,並在.txt文件中寫入文本。 這是Form1.cs的代碼:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace EasyManagementOrdine
{
    public partial class Form1 : Form
    {
        private const string FILE_NAME = "ESPORTAZIONE.txt";

        public List<string> listaString = new List<string>();

        public StreamWriter sw;

        public Form1()
        {
            try
            {
                InitializeComponent();
                if (File.Exists("ESPORTAZIONE.txt"))
                {
                    File.Delete("ESPORTAZIONE.txt");
                }
                this.sw = File.CreateText("ESPORTAZIONE.txt");
                //this.textQuantita.KeyPress.(new KeyPressEventHandler(this, CheckEnter));
                this.textCodiceBarre.Focus();
            }
            catch(Exception e)
            {

            }

        }

        private void codiceBarreEnter(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == '\r')
                {
                    if ((!this.textCodiceBarre.Focused ? false : this.textCodiceBarre.Text.Length > 0))
                    {
                        this.textQuantita.Focus();
                    }
                }
            }
            catch (Exception exception)
            {
                Exception ex = exception;
                MessageBox.Show(string.Concat("Errore: ", ex.Message));
            }
        }

        private void quantitaEnter(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == '\r')
                {
                    if ((!this.textQuantita.Focused ? false : this.textQuantita.Text.Length > 0))
                    {
                        this.salvaQuantita();
                    }
                }
            }
            catch (Exception exception)
            {
                Exception ex = exception;
                MessageBox.Show(string.Concat("Errore: ", ex.Message));
            }
        }

        private void salvaQuantita()
        {
            try
            {
                int numeroQuantita = int.Parse(this.textQuantita.Text);
                string nuovaStringa = string.Concat(this.textCodiceBarre.Text, " && ", numeroQuantita);
                this.sw.WriteLine(nuovaStringa);
                this.textCodiceBarre.Text = "";
                this.textQuantita.Text = "";
                this.textCodiceBarre.Focus();
            }
            catch (Exception exception)
            {
                Exception e = exception;
                MessageBox.Show(string.Concat("Errore: ", e.Message));
            }
        }

        private void buttonOrdine_Click(object sender, EventArgs e)
        {
            try
            {
                this.sw.Close();
                MessageBox.Show("Il file ESPORTAZIONE.txt è statp creato.", "Complimenti");
            }
            catch (Exception exception)
            {
                Exception ex = exception;
                MessageBox.Show(string.Concat("Errore: ", ex.Message));
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Environment.Exit(0);
            }
            catch (Exception exception)
            {
                String process = Process.GetCurrentProcess().ProcessName;
                Process.Start("cmd.exe", "/c taskkill /F /IM " + process + ".exe /T");
                Exception ex = exception;
                MessageBox.Show(string.Concat("Errore: ", ex.Message));
            }
        }
    }
}

問題是什么 ?

看完評論后....

您正在使用VS2017,但2010版本的Visual Studio不支持Windows Phone OS 7.0之前的Windows Phone版本的移動應用程序>開發。

https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/sa69he4t(v=vs.100)

您可能正在創建一個普通的Windows應用程序並嘗試將其復制到Windows CE,它不會那樣工作

您需要使用Visual Studio 2008

在那里,您將能夠找到適當的模板來創建Windows CE項目......

現在這無關緊要,但要記住它。

緊湊框架中不支持MessageBox類,因為.Show(String...)是一個重載

Show(IWin32Window, String, ...)

適用於

.NET Core 3.0預覽版3

.NET Framework 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6 4.5.2 4.5.1 4.5 4.0 3.5 3.0 2.0 1.1

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.messagebox?view=netframework-4.7.2

您需要使用Microsoft.WindowsCE.Forms命名空間中的MessageWindow

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM