我正在构建一个简单的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));
}
}
}
}
出什么问题了?
答案 0 :(得分:0)
阅读评论后......
您正在使用VS2017,但2010年版本的Visual Studio不支持移动应用程序> Windows Phone OS之前的Windows Phone版本的开发 7.0。
您可能正在创建一个普通的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
您需要使用MessageWindow
名称空间中的Microsoft.WindowsCE.Forms
类