0

I am building a simple Windows Forms Application.

It is very simple,on my Windows PC, it runs without any problems.

If I try to copy the .exe and .pdb file on my Windows Ce device and try to start it, I get this error:

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

My application has two simple textboxes and writes a text in a .txt file. This is the code of 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));
            }
        }
    }
}

What is the problem ?

Thewickedislick
  • 305
  • 1
  • 4
  • 14
bircastri
  • 2,169
  • 13
  • 50
  • 119

1 Answers1

0

After read the comments....

You are using VS2017, but Visual studio from 2010 version, does not support mobile application> development for versions of Windows Phone prior to Windows Phone OS 7.0.

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

You probably are creating a normal windows application and trying to copy it to Windows CE, it does not work that way

You neeed to use Visual Studio 2008

There you will be able to find the proper templates to create a Windows CE project...

This is irrelevant now but keep it in mind..

MessageBox class is not supported in compact framework as .Show(String...) is an overload of

Show(IWin32Window, String, ...)

Applies to

.NET Core 3.0 Preview 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://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.messagebox?view=netframework-4.7.2

You need to use MessageWindow class from Microsoft.WindowsCE.Forms namespace

Daniel Brughera
  • 1,641
  • 1
  • 7
  • 14