i got the following error when i try to run my C# Winform Application on Client Machine
Description:
Stopped working
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: ics.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 5134926a
Problem Signature 04: System.Data
Problem Signature 05: 2.0.0.0
Problem Signature 06: 4a275e65
Problem Signature 07: 2755
Problem Signature 08: 29
Problem Signature 09: System.Data.SqlClient.Sql
OS Version: 6.1.7600.2.0.0.768.2
Locale ID: 1033
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
and here is the Application.Run code
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmLogin2());
}
and here is the form Login Code
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 DevComponents.DotNetBar;
using ICS.Classes;
using System.Threading;
using Microsoft.Win32;
namespace ICS.Forms
{
public partial class frmLogin2 : Office2007Form
{
static DataAccess da = new DataAccess();
static DataTable dt = new DataTable();
int num = 0;
public frmLogin2()
{
Thread t = new Thread(new ThreadStart(SplashScreen));
t.Start();
Thread.Sleep(5000);
InitializeComponent();
t.Abort();
}
void Registries()
{
try
{
RegistryKey regKey;
regKey = Registry.LocalMachine.OpenSubKey(#"SOFTWARE\ICS\POS", true);
string activated = EncDec.Decrypt(regKey.GetValue("Activated").ToString(), "A!11").ToString();
if (activated != "TRUE")
{
string coder1;
coder1 = regKey.GetValue("ICSPOS").ToString().Trim();
num = int.Parse(EncDec.Decrypt(coder1, "A!11"));
if (num < 30)
{
num++;
regKey.SetValue("ICSPOS", EncDec.Encrypt(num.ToString(), "A!11"));
lblNum.Text += (30 - num).ToString();
}
}
}
catch (Exception ex)
{
string coder1 = "";
try
{
RegistryKey regKey;
regKey = Registry.LocalMachine.OpenSubKey(#"SOFTWARE\ICS\POS", true);
coder1 = regKey.GetValue("ICSPOS").ToString().Trim();
}
catch
{
}
RegistryKey creator;
creator = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
creator.CreateSubKey(#"ICS\POS");
creator.Close();
RegistryKey REG2;
REG2 = Registry.LocalMachine.OpenSubKey(#"SOFTWARE\ICS\POS", true);
REG2.SetValue("AppName", "POS");
REG2.SetValue("Version", 1.0);
REG2.SetValue("Activated", EncDec.Encrypt("No", "A!11"));
if (string.IsNullOrEmpty(coder1))
{
REG2.SetValue("ICSPOS", EncDec.Encrypt("1", "A!11"));
lblNum.Text += (30 - 1).ToString();
}
REG2.Close();
}
}
private void frmLogin2_Load(object sender, EventArgs e)
{
try
{
ICS_Auth aut = new ICS_Auth();
Registries();
//MessageBox.Show(aut.CreatSerial());
if (num == 1)
{
da.ExecuteNonQuery("sp_admin_user");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnLogin_Click(object sender, EventArgs e)
{
dt = da.GetDataTable("User_Login", da.CreateSqlParamter("#User_Name", txtUsername.Text)
, da.CreateSqlParamter("#User_Pass", txtUserpass.Text));
if (dt.Rows.Count == 1)
{
//this.Close();
frmMain main = new frmMain(dt);
main.Show();
this.Hide();
}
else
{
MessageBox.Show("اسم المستخدم او كلمة المرور غير صحيحة");
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
public void SplashScreen()
{
Application.Run(new frmSplash());
}
public static DataTable LOGIN()
{
frmLogin2 log = new frmLogin2();
log.ShowDialog();
return dt;
}
private void frmLogin2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)27)this.Close();
}
}
}
and here is connection string in app.config
<add key="ConnStr" value="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\POS.mdf;Integrated Security=True;User Instance=True"/>
And I'm using Visual Studio 2008 and SQL Server 2005 Express
Indeed, the problem is within the connection string, but not the Data Source= section. It is the User Instance=True
Unless you're absolutely positive about its need I suggest to remove it - the default value for User Instance is False.
I'm assuming the issue boils down to permissions/disk quotas and other sys admin related issues. Here you can find more on what the User Instance is and how to use it.
Your data source is the problem. You currently have:
Data Source=.\SQLEXPRESS
But what you need is (local) like this:
Data Source=(local)
Related
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 ?
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
I have a class defined to get live capture from a camera, and a form button "END CAPTURE" that should halt the capture; and an typical Application.Exit() button.
However, for some reason the while loop as shown below doesn't load the form even when the condition is met. To debug this, I commented out the while loop to see if it snaps at least 1 image; and it does (as shown in fig). What makes the while loop not to load the form and show the output continuously ?
while (!terminated)
{
// CAMERA ACQUISITION CODE
}
Figure of single while loop run:
Full program for reference:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using mv.impact.acquire;
using mv.impact.acquire.examples.helper;
namespace mv_BlueFoxControl
{
public partial class Form1 : Form
{
private bool button1WasClicked = false;
public Bitmap SnappedBitmap = null;
public static Image PersistentImage = null;
public Form1()
{
InitializeComponent();
mv.impact.acquire.LibraryPath.init(); // this will add the folders containing unmanaged libraries to the PATH variable.
Device pDev = DeviceManager.getDevice(0);// Get a pointer to the first device found
if (pDev == null)
{
Console.WriteLine("Unable to continue! No device found! Press any key to end the program.");
//Console.Read();
Environment.Exit(1);
}
Console.WriteLine("Initialising the device. This might take some time...");
try
{
pDev.open();//start the sensor
Console.WriteLine("Device opened successfully...");
}
catch (ImpactAcquireException e)
{
// throw error code if the same device is already opened in another process...
Console.WriteLine("An error occurred while opening the device " + pDev.serial +
"(error code: " + e.Message + "). Press any key to end the application...");
//Console.ReadLine();
Environment.Exit(1);
}
bool terminated = false;// Bool terminated was here.
Console.WriteLine("Press CAPTURE to end the application");
// create thread for live capture
Thread thread = new Thread(delegate()//Start live acquisition
{
DeviceAccess.manuallyStartAcquisitionIfNeeded(pDev, fi);
Request pRequest = null;
// we always have to keep at least 2 images as the display module might want to repaint the image, thus we
// can free it unless we have a assigned the display to a new buffer.
Request pPreviousRequest = null;
int timeout_ms = 500;
int cnt = 0;
int requestNr = Device.INVALID_ID;
Console.WriteLine(terminated);
while (!terminated)
{
// CAMERA ACQUISITON CODE
}
DeviceAccess.manuallyStopAcquisitionIfNeeded(pDev, fi);
// free the last potential locked request
if (pRequest != null)
{
pRequest.unlock();
}
// clear the request queue
fi.imageRequestReset(0, 0);
// extract and unlock all requests that are now returned as 'aborted'
requestNr = Device.INVALID_ID;
while ((requestNr = fi.imageRequestWaitFor(0)) >= 0)
{
pRequest = fi.getRequest(requestNr);
Console.WriteLine("Request {0} did return with status {1}", requestNr, pRequest.requestResult.readS());
pRequest.unlock();
}
});//End of thread
Console.WriteLine(" End Thread");
thread.Start();
if (button1WasClicked)
{
terminated = true;
}
Console.WriteLine("Program termination");
Console.WriteLine(terminated);
thread.Join();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
button1WasClicked = true;
}
}
}
Because of thread.Join(); The application will wait that the thread ends (which will not end until you press the button) and so the constructor is never finished.
You have to initialize a Thread field and only close it when you press the button.
Try this:
public partial class Form1 : Form
{
//...
private Thread _cameraThread;
public Form1()
{
//... the previous code
_cameraThread = new Thread(delegate()//Start live acquisition
{
// thread logic
});
_cameraThread.Start();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
button1WasClicked = true;
//set the flag and wait for the thread to finish
_cameraThread.Join();
Console.WriteLine("Program termination");
}
}
When debugging the code, Visual Studio gives me a "format exception was unhandled" while highlighting this line of code: 'CustObj.d_CustDiscount = Convert.ToDecimal(gs_InPutBuffer.Substring(000, 004));'
I have been googling correct formats and have not come up with any fixes. So my main question is, how do I rewrite this code in order for it to work?
Thanks for any help!
Below is the full program if you need to reference it:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using CustFile_DLL;
namespace FileConvertorPA03
{
class Program
{
//add these to handle I/O
//instatiate streamreader
private static StreamReader TextfileIn = new StreamReader("customers.txt");
//instantiate the dll
private static CustFileClass CustObj = new CustFileClass();
//a few vars
private static string gs_InPutBuffer = "";
private static Int32 gi_TotalRec = 0, gi_FirstRecNo = 0;
private static bool gb_FirstRec = true;
static void Main(string[] args)
{
while ((gs_InPutBuffer = TextfileIn.ReadLine()) != null)
{
ParsetoAttributes();
CustObj.AddObject();
}//end while
PopMessageBox();
TextfileIn.Close();
}//end main
//method to parse input buffer to class attributes
private static void ParsetoAttributes()
{
CustObj.s_CustName = gs_InPutBuffer.Substring(000, 033).Trim();
CustObj.s_CustAddress = gs_InPutBuffer.Substring(033, 032).Trim();
CustObj.s_CustZip = gs_InPutBuffer.Substring(065, 005);
CustObj.s_CustPhone = gs_InPutBuffer.Substring(070, 010);
CustObj.d_CustDiscount = Convert.ToDecimal(gs_InPutBuffer.Substring(000, 004));
}//end parse attributes
//method to count records added
static void CountRecs()
{
if (gb_FirstRec == true)
{
gi_FirstRecNo = CustObj.i_CustNumber;
gb_FirstRec = false;
}//end if
gi_TotalRec++;
}//end count recs
public static void PopMessageBox()
{
MessageBox.Show(String.Format("Message: \n\tRecords Added \t{0,6}n\tFirst Rec Added\t {1,6}\n\tLast Rec Added\t{2,6}",
gi_TotalRec, gi_FirstRecNo, CustObj.i_CustNumber),"File Conversion Message:",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}//end class
}
}//end namespace
Replace the ToDecimal call with the following to find out what the issue is:
try
{
CustObj.d_CustDiscount = Convert.ToDecimal(gs_InPutBuffer.Substring(0, 4));
}
catch (FormatException e)
{
Console.WriteLine(gs_InPutBuffer.Substring(0, 4));
Console.WriteLine(e.Message);
}
If this isn't a console application, you can change the code in the catch block to write out to a MessageBox. You can also leave out the leading zeros in the arguments to the calls to Substring.
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.Diagnostics;
using System.Security;
namespace SampleProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
String input = textBox1.Text;
try
{
Process ps = new Process();
ps.StartInfo.FileName = #"\\199.63.55.163\d$\hello.bat";
ps.StartInfo.Arguments = input;
ps.StartInfo.CreateNoWindow = false;
String domain = ps.StartInfo.Domain;
ps.StartInfo.RedirectStandardOutput = true;
ps.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
ps.StartInfo.WorkingDirectory = #"d:\praveen";
ps.StartInfo.UserName = "Raj";
ps.StartInfo.Domain = "domain";
ps.StartInfo.Password = Encrypt("Hello123");
ps.StartInfo.UseShellExecute = false;
ps.Start();
ps.WaitForExit();
MessageBox.Show(ps.StandardOutput.ReadToEnd());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void label1_Click(object sender, EventArgs e)
{
}
public static SecureString Encrypt(String pwd)
{
SecureString ss = new SecureString();
for (int i = 0; i < pwd.Length; i++)
{
ss.AppendChar(pwd[i]);
}
return ss;
}
}
}
It's a shot in the dark, but I think that you can't read the processes standard output once it has exited.
Also you have to redirect it - take a look at this documentation: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx
Duplicate of .NET Process Start Process Error using credentials (The handle is invalid) ? You need to assign RedirectStandardInput, RedirectStandardOutput, RedirectStandardError
I would like to run a set of commands that would typically be run in telnet(from c#).
For example I would like to run the following
using System;
using System.Diagnostics;
namespace InteractWithConsoleApp
{
class Program
{
static void Main(string[] args)
{
ProcessStartInfo cmdStartInfo = new ProcessStartInfo();
cmdStartInfo.FileName = #"C:\Windows\System32\cmd.exe";
cmdStartInfo.RedirectStandardOutput = true;
cmdStartInfo.RedirectStandardError = true;
cmdStartInfo.RedirectStandardInput = true;
cmdStartInfo.UseShellExecute = false;
cmdStartInfo.CreateNoWindow = true;
Process cmdProcess = new Process();
cmdProcess.StartInfo = cmdStartInfo;
cmdProcess.ErrorDataReceived += cmd_Error;
cmdProcess.OutputDataReceived += cmd_DataReceived;
cmdProcess.EnableRaisingEvents = true;
cmdProcess.Start();
cmdProcess.BeginOutputReadLine();
cmdProcess.BeginErrorReadLine();
cmdProcess.StandardInput.WriteLine("telnet telehack.com");
int milliseconds = 2000;
System.Threading.Thread.Sleep(milliseconds);
cmdProcess.StandardInput.WriteLine("exit");
cmdProcess.StandardInput.WriteLine("exit");
cmdProcess.WaitForExit();
}
static void cmd_DataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine(e.Data);
}
static void cmd_Error(object sender, DataReceivedEventArgs e)
{
Console.WriteLine(e.Data);
}
}
}
and keep telnet open to run subsequent commands. For example for the question above I would like to run and receive the following output, but I don't receive any of the telnet output. It doesn't receive any output. This is related.
telnet telehack.com
> Connected to TELEHACK port 53
It is 2:33 pm on Tuesday, September 1, 2015 in Mountain View, California, USA.
There are 31 local users. There are 24906 hosts on the network.
May the command line live forever.
Command, one of the following:
? ac advent basic cal calc
ching clear clock cowsay date echo
eliza factor figlet finger fnord geoip
help hosts ipaddr joke login md5
morse newuser notes octopus phoon pig
ping primes privacy rain rand rfc
rig roll rot13 sleep starwars traceroute
units uptime usenet users uumap uupath
uuplot weather when zc zork zrun
.calc
calc>2+2
> 4
Based on comments I understand that you can use actual telnet protocol implementation instead of calling to telnet.exe, so
Form1.cs
using MinimalisticTelnet;
using System;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace Telnet
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private MinimalisticTelnet.TelnetConnection _tc;
private void Form1_Load(object sender, EventArgs e)
{
_tc = new TelnetConnection("telehack.com", 23);
}
private void timer1_Tick(object sender, EventArgs e)
{
ProcessOutput();
}
private void btnSendCommand_Click(object sender, EventArgs e)
{
if (_tc.IsConnected)
{
_tc.WriteLine(tbCommand.Text.Trim());
tbCommand.Clear();
tbCommand.Focus();
ProcessOutput();
}
}
private void ProcessOutput()
{
if (!_tc.IsConnected)
return;
var s = _tc.Read();
s = Regex.Replace(s, #"\x1b\[([0-9,A-Z]{1,2}(;[0-9]{1,2})?(;[0-9]{3})?)?[m|K]?", "");
tbOutput.AppendText(s);
}
}
}
TelnetInterface.cs
// minimalistic telnet implementation
// conceived by Tom Janssens on 2007/06/06 for codeproject
//
// http://www.corebvba.be
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
namespace MinimalisticTelnet
{
enum Verbs
{
WILL = 251,
WONT = 252,
DO = 253,
DONT = 254,
IAC = 255
}
enum Options
{
SGA = 3
}
class TelnetConnection
{
TcpClient tcpSocket;
int TimeOutMs = 100;
public TelnetConnection(string Hostname, int Port)
{
tcpSocket = new TcpClient(Hostname, Port);
}
public string Login(string Username, string Password, int LoginTimeOutMs)
{
int oldTimeOutMs = TimeOutMs;
TimeOutMs = LoginTimeOutMs;
string s = Read();
if (!s.TrimEnd().EndsWith(":"))
throw new Exception("Failed to connect : no login prompt");
WriteLine(Username);
s += Read();
if (!s.TrimEnd().EndsWith(":"))
throw new Exception("Failed to connect : no password prompt");
WriteLine(Password);
s += Read();
TimeOutMs = oldTimeOutMs;
return s;
}
public void WriteLine(string cmd)
{
Write(cmd + Environment.NewLine);
}
public void Write(string cmd)
{
if (!tcpSocket.Connected) return;
byte[] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(cmd.Replace("\0xFF", "\0xFF\0xFF"));
tcpSocket.GetStream().Write(buf, 0, buf.Length);
}
public string Read()
{
if (!tcpSocket.Connected) return null;
StringBuilder sb = new StringBuilder();
do
{
ParseTelnet(sb);
System.Threading.Thread.Sleep(TimeOutMs);
} while (tcpSocket.Available > 0);
return sb.ToString();
}
public bool IsConnected
{
get { return tcpSocket.Connected; }
}
void ParseTelnet(StringBuilder sb)
{
while (tcpSocket.Available > 0)
{
int input = tcpSocket.GetStream().ReadByte();
switch (input)
{
case -1:
break;
case (int)Verbs.IAC:
// interpret as command
int inputverb = tcpSocket.GetStream().ReadByte();
if (inputverb == -1) break;
switch (inputverb)
{
case (int)Verbs.IAC:
//literal IAC = 255 escaped, so append char 255 to string
sb.Append(inputverb);
break;
case (int)Verbs.DO:
case (int)Verbs.DONT:
case (int)Verbs.WILL:
case (int)Verbs.WONT:
// reply to all commands with "WONT", unless it is SGA (suppres go ahead)
int inputoption = tcpSocket.GetStream().ReadByte();
if (inputoption == -1) break;
tcpSocket.GetStream().WriteByte((byte)Verbs.IAC);
if (inputoption == (int)Options.SGA)
tcpSocket.GetStream().WriteByte(inputverb == (int)Verbs.DO ? (byte)Verbs.WILL : (byte)Verbs.DO);
else
tcpSocket.GetStream().WriteByte(inputverb == (int)Verbs.DO ? (byte)Verbs.WONT : (byte)Verbs.DONT);
tcpSocket.GetStream().WriteByte((byte)inputoption);
break;
default:
break;
}
break;
default:
sb.Append((char)input);
break;
}
}
}
}
}
This is Windows Forms app with 2 textboxes and 1 button and a timer (interval is 1000ms).
I've used code from CodeProject (linked in original question) with some changes to make it actually work.
Coding this may be hard. However, there are free tools out there for Telnet scripting, see Expect for one. If you have an C# application then perhaps your code could generate the Expect script and then run Expect?
Sending the information to telnet seems like it should be straightforward; use SendKeys(). The question becomes how to capture the output.
I found this YouTube video that should help: https://www.youtube.com/watch?v=BDTCviA-5M8
The solution in the video doesn't really address keeping the session open. I'm a bit outside my knowledge area here, but I believe you can start telnet in a worker thread, send commands to it with SendKeys(), capture the output as described in the video, then parse it.
Does that sufficiently resolve the requirement?