Excellent idea and thanks for the post. I will definitely try this out in some other projects as well.
As a matter of interest, you were quite right in your original post that an exhaustive search (with something like foreach) really doesn't take as much time as one would have thought. I'm amazed at how quickly it runs through 9000 entries.
I want to write a windows application that doesn’t have a form, that is no input or output.
I have tried the console project but that causes a CMD box to flash up, I have tried the windows service option but this doesn’t allow it to be run from the command line.
This is what I want to do:
My application will be launched from a function key in our main application (uses Shellexecute) it then checks some items and launches another existing application.
you can do it like that:
Process p = new Process();
//Fill the StartInfo of the Process----"cmd.exe"
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;//important
p.StartInfo.RedirectStandardOutput = true;//important
p.StartInfo.RedirectStandardError = false;//true,the same...
p.StartInfo.CreateNoWindow = true;//important
p.Start();//start the process
p.StandardInput.WriteLine("ping www.google.com ");
// below...you want
if (strResult.IndexOf("( 0% loss )") != -1)
if (strResult.IndexOf("Destination host unreachable.") != -1)
if (strResult.IndexOf("Request timed out.") != -1)
if (strResult.IndexOf("Unknown host") != -1)
// if end
Thanks for the answer, it's very good.
But I have a problem, the command that I am running is "tftp.exe..."
when the transfer is successful I got the whole answer using the ReadToEnd function but when there is no tftp or the file doesn't exist I get only my command that I have sent I would expect to see "Timeout" or "File not found" as I see when I run the same command on the cmd prompt. Any Idea?
I am using visual studio .net 2008 and developing a windows forms application.
I want to use databinding and keep the business/validation logic in a separate layer (other than presentation layer).
The validation may be performed in ColumnChanged event or RowChanged event(depending upon user preference) of the datatable of the dataset.
validation error message must be shown in a Message Box
if validation is performed in ColumnChanged event and there are validation errors then the focus should be set to the control that has the validation errors.
if validation is performed in RowChanged event (i.e. user hitting the save button) and there are validation errors, then the focus should be set to the control which comes first in the tab order and has validation errors.
i have made setup project. but after deploying project, when i m trying to see it's giving me runtime error as below :
I have added crystal report as prerequisites ans also added reports to the appliction folder..
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Exception: Load report failed. ---> System.Runtime.InteropServices.COMException (0x80004005): The system cannot find the path specified. at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
--- End of inner exception stack trace ---
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
at DPRMS.ReportViewer.btnshow_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
If you are truly in a "Popup" (i.e. a modal dialog box), simply overload the ShowDialog method in your "popup" form to call the base implementation of ShowDialog and return the value that you want to have passed back.
private List<t> list;
protected void btnSubmit_Click(object sender, EventArgs e)
list = DataGrid.DataSource; //I pulled this property off the top of my head. You'll have to play
public List<t> ShowDialog()
Have the "OK" button (or whatever flow control you have in place) set the variable you wish to return and close the form.
Use delegates. There's plenty of examples here and on the internet.
Here's a very simple example to get you started.
Create a Windows Forms Application and call it DelegateExample.
You'll already have Form1. Add another form and call it Form2 then add a TextBox to it called textBox1.
Change all the code in Form1.cs to this:
public delegate void UpdateText(string text);
public partial class Form1 : Form
private void Form1_Load(object sender, EventArgs e)
Form2 frm2 = new Form2();
frm2.SendText = new UpdateText(Update);
private void Update(string text)
Text = text;
Change all the code in Form2.cs to this:
public partial class Form2 : Form
public UpdateText SendText;
private void textBox1_TextChanged(object sender, EventArgs e)
When you run this - type in the TextBox on Form2 and the Text in the title bar of Form1 will change as you type.
Study the code so you understand what it's doing then you can use this principal in your situation with very little modification.
Dave BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
it's my first question in this site and I don't know if this one is the right forum.
I've downloaded a C# project from Desktop Development -> Progress Bar called ProgressCircle written by Utezduyar.
I extracted the zip file and I loaded in Visual Studio.
In instruction Initialize Components (the first instruction of the code) program stops and errors says "Impossible to load file or assembly 'ProgressCircle, Version=...., PublicKeyToken=....'. Impossible to warrant the authorization. (Exception HRESULT: 0x80131417).
In ProgressCircle project there is a key.snk file maybe the project is protected.
I have no idea.
Thanks in advance,