|
rachel_m wrote: Thus can you tell me what I can do to resolve my problem? Not without a lot more information. Remember, we cannot see what happens when you run your program, and we have no idea what it is trying to do. At the very least you should show the error message that you receive.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
The error messages says it can not find the specified directory location. However the name of the seond progam that is called is from an old location where the second program used to be at. However that is not the location where I am speficying that the second program should be executed from.
I have no idea how the first program calls the second wrong with the wrong directory path. Do I need to keep the path of the second console application static?
|
|
|
|
|
Rather than paraphrasing what you think is happening, why not show us the exact code that calls the second program, and the exact error message that gets produced. Without specific details of what is going on it is impossible for us to do any more than make guesses.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
There can be any one of a million things wrong. We don't have enough information to tell you anything useful at all.
|
|
|
|
|
The error messages says it can not find the specified directory location. However the name of the second progam that is called is from an old location where the second program used to be at. However that is not the location where I am speficying that the second program should be executed from.
I have no idea how the first program calls the second wrong with the wrong directory path. Do I need to keep the path of the second console application static?
|
|
|
|
|
There still isn't enough information.
From the error message, the path that you supplied to Process to start doesn't exist. Whatever you think it tried to launch is not what's important here. It's what the code thought when it tried to launch this second process.
You have to step through the code in the debugger or instrument the code to log what it's doing and what key variable values are to a file.
|
|
|
|
|
Are you and this person working on the same code? Link
|
|
|
|
|
rachel_m wrote: In a C# 2010 console application it work works fine until it gets to a certain spot. Basically this console application calls another console application.
Here is what is happening:
Probably because of the following
1. You are not doing error checking when you use Process
2. You are making assumptions about the output of the second app which are not true.
|
|
|
|
|
You mentioned the followed:
Probably because of the following
1. You are not doing error checking when you use Process
2. You are making assumptions about the output of the second app which are not true.
I have a try catch block in the code that calls the second application. Is that not enough code. If not, what other error checking do you suggest I use?
You mentioned, " You are making assumptions about the output of the second app which are not true.". Can you tell me what I can do to make certain the second assumption is not true. What do you suggest I do so I do not make any assumptions?
|
|
|
|
|
Your descriptions are not enough. You must show the code!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
The following is an example of the code I am referring to:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.ComponentModel;
namespace eScripts
{
class Run_e
{
private static String strConsoleAppLocation = "C:\\Program Files (x86)\\coname\\1.exe";
private static String strWebServiceurl = "https://etest//WebService1";
static void Main(string[] args)
{
Process eProcess = new Process();
try
{
String Process_Arguments = null;
eProcess.StartInfo.UseShellExecute = false;
eProcess.StartInfo.FileName = strConsoleAppLocation;
Process_Arguments = strWebServiceurl + " 164 " + cust1";
eProcess.StartInfo.Arguments = Process_Arguments;
eProcess.Start();
eProcess.WaitForExit(1800);
Process_Arguments = null;
eDataContext rptData = new eDataContext();
string[] PkgIDs = rData.Trackings.Where(c => c.Received_Date != null
.Select(c => c.Package_ID).ToArray();
foreach (string PkgID in PkgIDs)
{
String Process1_Arguments = null;
Process Process1 = new Process();
Process1.StartInfo.FileName = strConsoleAppLocation;
Process1_Arguments = strWebServiceurl + " 10 " + PkgID;
Process1.StartInfo.Arguments = Process1_Arguments;
Process1.Start();
Process1.WaitForExit(1800);
Process1.Dispose();
Process1_Arguments = null;
}
ateTime StartDateTime = rData.Trackings.Where(c => c.Error_Report_Date != null).Select(c => c.Error_Report_Date).Max().GetValueOrDefault();
DateTime CurDateTime = DateTime.Now;
string[] AddPkgIDs = (from rData.Trackings.where(c.tNumber.Substring(0, 3) == "dis"
select TNumb).Distinct().ToArray();
if (AddPkgIDs != null)
{
foreach (string AddPkgID in AddPkgIDs)
{
String Process4_Arguments = null;
Process Process4 = new Process();
Process4.StartInfo.FileName = strConsoleAppLocation;
Process4_Arguments = strWebServiceurl + " 14295 " + AddPkgID;
Process4.StartInfo.Arguments = Process4_Arguments;
Process4.Start();
Process4.WaitForExit(1800); //waits 2 minutes
Process4.Dispose();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
The line of code that says,
private static String strConsoleAppLocation = "C:\\Program Files (x86)\\coname\\1.exe";
was orginally setup to be
private static String strConsoleAppLocation = "C:\\allcustomers\\country\\state\\city\customername\\1.exe";
modified 21-Oct-12 20:02pm.
|
|
|
|
|
In my opinion, you have too much code inside the try block. The error could be anywhere, and all you are seeing is the error message, but not where it is happening.
Remove the try catch blocks and run it again in the debugger. Then you'll find out where the error is happening.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
rachel_m wrote: I have a try catch block in the code that calls the second application.
Process represents a distinct operating system application. There is no way for exceptions to propogate across the process boundary.
However Process methods do have return values. Which you are ignoring.
rachel_m wrote: Can you tell me what I can do to make certain the second assumption is not true
Insure that you can read both zero bytes and a very large number of bytes from stdout and stderr. And if you are not otherwise processing those for specific output then collect it somewhere so you can inspect it for errors and unexpected output.
|
|
|
|
|
whats delegate concept in c# ?
thanks for any simple explain for this concept
|
|
|
|
|
Whenever you have a question regarding base framework things like this, you should first put that into google and then pick the link to the MSDN documentation. In most cases, this will be one of the first 3 links and is the best documentation to start learning from. Cheers.
Delegates[^]
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
|
You are welcome. Cheers.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Actually that question has been asked here many times, try searching delegates in this forum, you will find many explanations and some of them are more enlightening that the MSDN doco.
I find some forum explanations to be easier to understand than microsofts own interpretation.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Friends,
I need javascript coding for textbox to allow only alphabets on key press,
provide me solution
Thanks
|
|
|
|
|
ks.vignesh wrote: javascript coding
Asking for javascript code in the C# forum is not likely to get you a whole bunch of relevant answers.
http://www.codeproject.com/Forums/1580226/JavaScript.aspx[^]
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Voted 1 for (i) wrong forum (this has nothing to do with C#) and (ii) 'gimme codez' – we are not here to 'provide you solution' to a problem, that is what Google is for; CP is for asking specific questions when you are having a problem with an isolated aspect of your code.
|
|
|
|
|
|
Using Scalabledesktop dll it is possible...?
|
|
|
|
|
The best placed people to answer that question are here[^]. Whenever you have a vendor specific problem, you should always think that they would be the best source for answers.
|
|
|
|
|
I have A string that contain a Sentence.
i have write 5 diff words from 5 diff language into this string .
string Words = "this is English , این فارسی است , c'est françaises ,यह भारतीय है,это Россия"
how to determine the words language , i mean how to know which word belong to which language .
i hope you get what i mean .
any idea w'll be helpfull.
|
|
|
|