При запуске приложения на турецкой системе программа вываливается с ошибкой - C#
Формулировка задачи:
В чем может быть проблема? При запуске приложения на турецкой системе программа вываливается с ошибкой...
Может быть дело в локали системы?
<?xml version="1.0" encoding="UTF-16"?> <DATABASE> <EXE NAME="ЕвроКомплект Счетчик Стеклопакетов(Andruino).exe" FILTER="CMI_FILTER_PRIVACY"> <MATCHING_FILE NAME="MySql.Data.dll" SIZE="376832" CHECKSUM="0xCF05FF15" BIN_FILE_VERSION="6.5.4.0" BIN_PRODUCT_VERSION="6.5.4.0" PRODUCT_VERSION="6.5.4.0" FILE_DESCRIPTION="MySql.Data.dll" COMPANY_NAME="Oracle" FILE_VERSION="6.5.4.0" ORIGINAL_FILENAME="MySql.Data.dll" INTERNAL_NAME="MySql.Data.dll" LEGAL_COPYRIGHT="Copyright © 2004, 2010, Oracle and/or its affiliates. All rights reserved." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x5CFB2" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.5.4.0" UPTO_BIN_PRODUCT_VERSION="6.5.4.0" LINK_DATE="03/05/2012 20:19:06" UPTO_LINK_DATE="03/05/2012 20:19:06" VER_LANGUAGE="Language Neutral [0x0]" EXE_WRAPPER="0x0" /> <MATCHING_FILE NAME="ЕвроКомплект Счетчик Стеклопакетов(Andruino).exe" SIZE="188928" CHECKSUM="0x34E29F53" BIN_FILE_VERSION="1.0.0.0" BIN_PRODUCT_VERSION="1.0.0.0" PRODUCT_VERSION="1.0.0.0" FILE_DESCRIPTION="ЕвроКомплект Счетчик Стеклопакетов(Andruino)" PRODUCT_NAME="ЕвроКомплект Счетчик Стеклопакетов(Andruino)" FILE_VERSION="1.0.0.0" ORIGINAL_FILENAME="ЕвроКомплект Счетчик Стеклопакетов(Andruino).exe" INTERNAL_NAME="ЕвроКомплект Счетчик Стеклопакетов(Andruino).exe" LEGAL_COPYRIGHT="Copyright © 2014" VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="1.0.0.0" UPTO_BIN_PRODUCT_VERSION="1.0.0.0" LINK_DATE="10/28/2014 03:55:49" UPTO_LINK_DATE="10/28/2014 03:55:49" VER_LANGUAGE="Language Neutral [0x0]" EXE_WRAPPER="0x0" /> <MATCHING_FILE NAME="ЕвроКомплект Счетчик Стеклопакетов(Andruino).vshost.exe" SIZE="11600" CHECKSUM="0x457DC41D" BIN_FILE_VERSION="10.0.30319.1" BIN_PRODUCT_VERSION="10.0.30319.1" PRODUCT_VERSION="10.0.30319.1" FILE_DESCRIPTION="vshost32.exe" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft (R) Visual Studio (R) 2010" FILE_VERSION="10.0.30319.1" ORIGINAL_FILENAME="vshost32.exe" INTERNAL_NAME="vshost32.exe" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x4CDB" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="10.0.30319.1" UPTO_BIN_PRODUCT_VERSION="10.0.30319.1" LINK_DATE="03/18/2010 11:02:35" UPTO_LINK_DATE="03/18/2010 11:02:35" VER_LANGUAGE="Language Neutral [0x0]" EXE_WRAPPER="0x0" /> <MATCHING_FILE NAME="en-EDU-biotime\ЕвроКомплект Счетчик Стеклопакетов(Andruino).resources.dll" SIZE="74752" CHECKSUM="0x490821A8" BIN_FILE_VERSION="1.0.0.0" BIN_PRODUCT_VERSION="1.0.0.0" PRODUCT_VERSION="1.0.0.0" FILE_DESCRIPTION="ЕвроКомплект Счетчик Стеклопакетов(Andruino)" PRODUCT_NAME="ЕвроКомплект Счетчик Стеклопакетов(Andruino)" FILE_VERSION="1.0.0.0" ORIGINAL_FILENAME="ЕвроКомплект Счетчик Стеклопакетов(Andruino).resources.dll" INTERNAL_NAME="ЕвроКомплект Счетчик Стеклопакетов(Andruino).resources.dll" LEGAL_COPYRIGHT="Copyright © 2014" VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="1.0.0.0" UPTO_BIN_PRODUCT_VERSION="1.0.0.0" LINK_DATE="10/28/2014 03:55:49" UPTO_LINK_DATE="10/28/2014 03:55:49" VER_LANGUAGE="Language Neutral [0x0]" EXE_WRAPPER="0x0" /> </EXE> <EXE NAME="KERNELBASE.dll" FILTER="CMI_FILTER_THISFILEONLY"> <MATCHING_FILE NAME="KernelBase.dll" SIZE="272384" CHECKSUM="0x41CCF929" BIN_FILE_VERSION="6.1.7600.16850" BIN_PRODUCT_VERSION="6.1.7600.16850" PRODUCT_VERSION="6.1.7600.16385" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="6.1.7600.16385 (win7_rtm.090713-1255)" ORIGINAL_FILENAME="Kernelbase" INTERNAL_NAME="Kernelbase" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x486EF" LINKER_VERSION="0x60001" UPTO_BIN_FILE_VERSION="6.1.7600.16850" UPTO_BIN_PRODUCT_VERSION="6.1.7600.16850" LINK_DATE="07/16/2011 04:33:09" UPTO_LINK_DATE="07/16/2011 04:33:09" EXPORT_NAME="KERNELBASE.dll" VER_LANGUAGE="English (United States) [0x409]" EXE_WRAPPER="0x0" FILE_ID="00008f87be9870b3ae8548dc278f6f09e0e5144dd038" PROGRAM_ID="0000f519feec486de87ed73cb92d3cac802400000000" /> </EXE> <EXE NAME="kernel32.dll" FILTER="CMI_FILTER_THISFILEONLY"> <MATCHING_FILE NAME="kernel32.dll" SIZE="1048576" CHECKSUM="0x2E98E39A" BIN_FILE_VERSION="6.1.7600.16850" BIN_PRODUCT_VERSION="6.1.7600.16850" PRODUCT_VERSION="6.1.7600.16385" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="6.1.7600.16385 (win7_rtm.090713-1255)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x10F4A4" LINKER_VERSION="0x60001" UPTO_BIN_FILE_VERSION="6.1.7600.16850" UPTO_BIN_PRODUCT_VERSION="6.1.7600.16850" LINK_DATE="07/16/2011 04:33:08" UPTO_LINK_DATE="07/16/2011 04:33:08" EXPORT_NAME="KERNEL32.dll" VER_LANGUAGE="English (United States) [0x409]" EXE_WRAPPER="0x0" FILE_ID="00008bf5690fa7cfef05e71ecda3440904222adf216b" PROGRAM_ID="0000f519feec486de87ed73cb92d3cac802400000000" /> </EXE> </DATABASE>
Решение задачи: «При запуске приложения на турецкой системе программа вываливается с ошибкой»
textual
Листинг программы
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO.Ports; using Microsoft.Win32; using System.Threading; namespace ЕвроКомплект_Счетчик_Стеклопакетов_Andruino_ { public partial class FrmMain : Form { public static string connstr = "Database=management_company;Data Source=192.168.1.1;Port=3306;User Id=notlive;Password=******;charset=cp1251"; public static SerialPort mySerialPortK = new SerialPort(); public int writeCount = 0; public int baseCount = 0; public int noConnectCount = 0; public bool summed = false; public string portArduino; public static RegistryKey rk; public static Thread readComPort; public static Thread connectCheck; public bool connStatus = false; public FrmMain() { InitializeComponent(); pictureBox1.Visible = false; LoadPorts(); GetSettingsPort(); OpenPort(); readComPort = new Thread(ReadData); readComPort.Start(); connectCheck = new Thread(ChConn); connectCheck.Start(); } string GetSettingsPort() { string port = ""; rk = Registry.Users.CreateSubKey(System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString() + "\\Software\\EuroKomplektCountGlassAndruino\\"); try { port = rk.GetValue("Port").ToString(); } catch { MessageBox.Show("Selected port from sensor and save settings!","No selected port sensor"); } try { noConnectCount = Convert.ToInt32(rk.GetValue("noConnectCount").ToString()); } catch { rk.SetValue("noConnectCount", "0"); } return port; } void ChConn() { while (true) { try { DataSet ds = new DataSet(); ds = SqlQuery.ExecuteReader(connstr, "SELECT `count` FROM PlantTimeGlass WHERE date = '" + Function.ConvertDateForBase(DateTime.Now.ToShortDateString(), false) + "' AND hover = '" + DateTime.Now.Hour.ToString() + "'"); if (ds.Tables[0].Rows.Count != 0) { baseCount = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString()); } else { baseCount = 0; } connStatus = true; } catch { connStatus = false; } } } int LoadPorts() { string[] ports = SerialPort.GetPortNames(); cbPorts.Items.Clear(); cbPorts.Items.AddRange(ports); if (cbPorts.Items.Count != 0) cbPorts.SelectedIndex = 0; if (GetSettingsPort() != "") cbPorts.SelectedItem = GetSettingsPort(); if (cbPorts.Items.Count == 0) { MessageBox.Show("No com ports on system.", "No com ports"); Application.Exit(); } return cbPorts.Items.Count; } void OpenPort() { //Открытие порта станка try { mySerialPortK.PortName = cbPorts.SelectedItem.ToString(); mySerialPortK.BaudRate = 9600; mySerialPortK.Parity = Parity.None; mySerialPortK.StopBits = StopBits.One; mySerialPortK.DataBits = 8; mySerialPortK.Handshake = Handshake.None; mySerialPortK.Open(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error open port from sensor!"); } } private void ReadData() { while (true) { string indata = mySerialPortK.ReadLine(); indata = indata.Replace("\n", ""); indata = indata.Replace("\r", ""); if (indata == "1") { this.Invoke(new Action(() => { pictureBox1.Visible = true; })); if (summed == false) { summed = true; if (connStatus) { writeCount = Convert.ToInt32(rk.GetValue("noConnectCount")) + baseCount + 1; WriteDataToBase(); digitalDay.Text = writeCount.ToString(); noConnectCount = 0; rk.SetValue("noConnectCount", "0"); } else { noConnectCount++; rk.SetValue("noConnectCount", noConnectCount.ToString()); digitalDay.Text = Convert.ToString(Convert.ToInt32(digitalDay.Text) + 1); } } } else { this.Invoke(new Action(() => { pictureBox1.Visible = false; })); summed = false; } } } private void toolStripButton1_Click(object sender, EventArgs e) { rk.SetValue("Port", cbPorts.SelectedItem); } private void FrmMain_FormClosing(object sender, FormClosingEventArgs e) { readComPort.Abort(); connectCheck.Abort(); mySerialPortK.Close(); } private void timer_Tick(object sender, EventArgs e) { digitalTime.Text = DateTime.Now.ToLongTimeString(); } private void cbSoundDisable_CheckedChanged(object sender, EventArgs e) { if (cbSoundDisable.Checked) { mySerialPortK.Write("0"); } else { mySerialPortK.Write("1"); } } private void toolStripButton2_Click(object sender, EventArgs e) { mySerialPortK.Write("r"); //Thread.Sleep(1500); cbSoundDisable_CheckedChanged(sender, e); } void WriteDataToBase() { try { DataSet ds = new DataSet(); ds = SqlQuery.ExecuteReader(connstr, "SELECT `count` FROM PlantTimeGlass WHERE date = '" + Function.ConvertDateForBase(DateTime.Now.ToShortDateString(), false) + "' AND hover = '" + DateTime.Now.Hour.ToString() + "'"); if (ds.Tables[0].Rows.Count != 0) { SqlQuery.Execute(connstr, "UPDATE PlantTimeGlass SET count = '" + writeCount.ToString() + "' WHERE date = '" + Function.ConvertDateForBase(DateTime.Now.ToShortDateString(), false) + "' AND hover = '" + DateTime.Now.Hour.ToString() + "'"); } else { SqlQuery.Execute(connstr, "INSERT INTO PlantTimeGlass VALUE(null, '" + Function.ConvertDateForBase(DateTime.Now.ToShortDateString(), false) + "', '" + DateTime.Now.Hour.ToString() + "', '" + Convert.ToString(1 + noConnectCount) + "')"); } } catch { } } } }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д