|
Thanks Alan,
I'm going to start with something posted above, then I'll do this too. It'll take me a bit to make the changes.
|
|
|
|
|
ok, I'm an embedded programmer, so that took me a little bit to wrap my head around. I don't think the problem is in the StudioCommandPrompt as I can't get my program to feed input to cmd.exe either. Below is a chunk of test code I put together to just test the connection all together, and it still outputs nothing.
Process Temp = System.Diagnostics.Process.Start("CMD.exe");
Temp.StartInfo.UseShellExecute = false;
Temp.StartInfo.RedirectStandardInput = true;
Temp.StartInfo.RedirectStandardOutput = true;
Temp.StartInfo.RedirectStandardError = true;
Temp.Start();
Temp.StandardInput.WriteLine("Test");
Temp.Close();
|
|
|
|
|
OK here's the improved version of your program (it's a console program)
I'll list what I've done:
1) Fix error: you had used Process.Start twice
2) Assigned a handler for the OutputDataReceived event. Redirected output is prefixed REDIR to differentiate from normal program output.
3) Activated Exited event and and assigned a handler
4) Error not redirected (makes the test simpler)
5) Start reading redirected standard output after Process.Start()
6) Issue DIR command
7) Issue SET command (to dump the environment variables)
8) Issue EXIT command to close cmd.exe
[EDIT forgot this]
9) Don't close the Process object
using System;
using System.Diagnostics;
namespace AdamB {
class Program {
static void Main(string[] args) {
Console.WriteLine("AdamB Test app");
RedirectionTest();
Console.WriteLine("Press Enter to end when output is complete...");
Console.WriteLine();
Console.ReadLine();
}
private static void RedirectionTest() {
Process Temp = new Process();
Temp.StartInfo.FileName = "cmd.exe";
Temp.StartInfo.UseShellExecute = false;
Temp.StartInfo.RedirectStandardInput = true;
Temp.StartInfo.RedirectStandardOutput = true;
Temp.OutputDataReceived += new DataReceivedEventHandler(Temp_OutputDataReceived);
Temp.EnableRaisingEvents = true;
Temp.Exited += new EventHandler(Temp_Exited);
Temp.Start();
Temp.BeginOutputReadLine();
Console.WriteLine("Sending DIR");
Temp.StandardInput.WriteLine("DIR");
Console.WriteLine("Sending SET");
Temp.StandardInput.WriteLine("SET");
Console.WriteLine("Sending EXIT");
Temp.StandardInput.WriteLine("EXIT");
}
static void Temp_Exited(object sender, EventArgs e) {
Console.WriteLine("MESSAGE: The process has exited");
}
static void Temp_OutputDataReceived(object sender, DataReceivedEventArgs e) {
Console.WriteLine("REDIR {0}", e.Data ?? "Null received -> Output stream has closed");
}
}
}
It's not usual for all commands to be issued before any redirected output appears on the screen and for the Exited event to occur while output is still arriving. Output has finished when the redirected stream is closed and that is signalled by e.Data == null.
Understanding all this redirection stuff is not easy if you are taking your cues from the Microsoft documentation as the examples are poor.
I'll look for more questions tomorrow.
Alan.
modified 14-Feb-13 16:40pm.
|
|
|
|
|
Alan N wrote: cmd < inputcommands.txt > stdout.txt 2>stderr.txt
Clever.
Obvious when I saw it but certainly can't remember ever considering that option in the many times I have messed with programmatic access to stdin/out.
|
|
|
|
|
I gave this a quick try yesterday, but I don't really understand what's going on in his example. I assume it didn't work because I broke it :P
|
|
|
|
|
adam.m.b.nelson wrote: but I don't really understand what's going on in his example.
How so? The one file provides input lines. Nothing else.
The output is irrelevant except as a tool to help you.
If you can't get the input lines to work then you need to work on getting the right values or the application is coded in such a way that it will NEVER work with this type of process.
|
|
|
|
|
I am doing final year project on the topic object recognition using c#. I am having problem that I didn't have any idea how to use neural network. Since my concept is to recognize the any types of object having different shape and size like human, ball, car. Since I have very few days so anybody can u help me. plz give me some idea with some sample code of object recognition.
|
|
|
|
|
manoj dhunelg wrote: Since I have very few days Then you have a lot of work to do; start here[^].
|
|
|
|
|
You have "very few days" for a final year project? And you picked THIS topic?? What do you mean by "very few days"?? How many are we talking about?? If it's a couple of weeks, you MIGHT be able to pull this off by pulling very long days to work on this project, but since you don't have any neural network experience, I seriously doubt it.
|
|
|
|
|
Hi
I need to force users to write in and fill forms using "English". And they cant be able to change language by pressing "Alt+ Shift".
thanks a lot for your helps...
|
|
|
|
|
Now that's all very nice, but you forgot to ask a question.
Regards,
Manfred
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
This would be tricky. If you just want to ensure script used is English, it is easy. Just scan every character in the input and make sure all the characters are valid English letters. But user can write another language using the English script. Detecting this would be tough and you need to use some natural language processing libraries.
Best wishes,
Navaneeth
|
|
|
|
|
Why does it matter? In "English" you can still type random crap in the form (and if you think that means ascii-only, consider pasting and alt-codes), so you'd still have to deal with it.
|
|
|
|
|
a simple way is in textbox keypress event! check if user pressed alt or shift , show a messagebox and inform to user that he/she cant use this feature
and if user changed language before activating textbox, you can check first charecter with textchanged event, if it is a charecter belong to persian (for example) ... with a message box say to user must change his/her language first
|
|
|
|
|
Spell check using an english dictionary.
|
|
|
|
|
i am trying to download some data from one website i succesfully navigate to the page and invoke click and it is navigate to next page .in the second page there is an iframe which is loading from another url . when am checking document text in my documentcompleted event handler the iframe part is showing youdont have permission to acces the page but in webbrowser control the whole page is showing..
Can anyone have any idea about the problem?
|
|
|
|
|
If iframe is pointing to a different domain, you will not get access to manipulate it's contents. This is basic security model exposed by browsers. I think you won't be able to workaround this. Check out this[^] MSDN article.
Best wishes,
Navaneeth
|
|
|
|
|
Hey Guys,
I know I can access my ItemTemplated Checkbox this way:
foreach (GridViewRow rowItem in GridView1.Rows)
{
CheckBox ckBxSelect = ((CheckBox)rowItem.FindControl("chkBxSelect"));
if (ckBxSelect.Checked)
{
Response.Write("True");
}
}
Ive built 1 LINQ object joined from 2 Datatables which comes from 2 WebServices. My GridView is bound to my LINQ object. When the user clicks submit, a foreach loop inserts that LINQ object into my database like so:
protected void Button1_Click(object sender, EventArgs e)
{
mySQLDatabaseDataContext dbc = new mySQLDatabaseDataContext("Data Source=JBBBZ7V1\\SQLEXPRESS;Initial Catalog=WLSData;Integrated Security=True");
mySQLTableName newRecord;
foreach (var item in LINQobject)
{
newRecord = new mySQLTableName();
newRecord.CustName = forAppr.custName;
newRecord.Status = "";
newRecord.DateTimeSubmitted = DateTime.Now;
dbc.mySQLTableName.InsertOnSubmit(newRecord);
}
dbc.SubmitChanges();
}
Like I said, my checkbox is in a TemplateField like so:
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
GridLines="Both"
CssClass="mGrid">
<Columns>
<asp:TemplateField HeaderText="Select">
<HeaderTemplate>
<asp:CheckBox ID="chkBxHeader" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkBxSelect" runat="server"/>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
</asp:TemplateField>
</Columns></asp:GridView>
When I am inserting from my LINQ object, I would like the "Status" field to update with "True" if checkbox is checked or "False" if checkbox is not checked. Like so:
protected void Button1_Click(object sender, EventArgs e)
{
mySQLDatabaseDataContext dbc = new mySQLDatabaseDataContext("Data Source=JBBBZ7V1\\SQLEXPRESS;Initial Catalog=WLSData;Integrated Security=True");
mySQLTableName newRecord;
foreach (var item in LINQobject)
{
newRecord = new mySQLTableName();
newRecord.CustName = forAppr.custName;
if(ckBxSelect.Checked)
{
newRecord.Status = "True";
}
Else
{
newRecord.Status = "False";
}
newRecord.DateTimeSubmitted = DateTime.Now;
dbc.mySQLTableName.InsertOnSubmit(newRecord);
}
dbc.SubmitChanges();
}
However,
This code will throw an exception because of the object not being set to a reference.
Please help. Is there a better way do update my database?
Im totally lost.
|
|
|
|
|
|
RickSharp wrote: This code will throw an exception because of the object not being set to a reference. Then you need to fix that bug. Glancing at your code it seems you are using the variable ckBxSelect without setting it to refer to any object.
|
|
|
|
|
The only way I know how to refer to a checkbox in a TemplateField is by using GridViewRow in a foreach loop. If there is another way to find that control then i would love to know.
|
|
|
|
|
I don't know what relevance this has to do with my comment. If you do not understand the error "object not being set to a reference", then I would suggest rereading your C# documentation on objects and references.
|
|
|
|
|
Thanks for the insight. I'll go reread my C# manual...
So i read it, and I guess I'm too stupid to understand it. Maybe someone else can help.
|
|
|
|
|
I have resolved this issue by reading an asp lablel key into a dictionary. then if the dictionary had that label insert into my database. Sorry if I was vague but I'm very new to all of this so I mostly i just make others made by asking inane questions that are apparently to unclear to understand.
|
|
|
|
|
In a C# 2008 windows application, my initial install of the code obtained the message,
"Cannot access a disposed object.". This was valid at the time.
However now I corrected the problem in the code and reinstalled the corrected application. I am still getting the error message, "Cannot access a disposed object.".
Thus my question is once I reinstalled the corrected code why would I still be getting the message,
"Cannot access a disposed object."?
|
|
|
|