|
Thank you! Seems to work (just tried it with a short piece of code - going to check it within my project later).
|
|
|
|
|
I have a C# 2010 console application that calls a web service where I am having a problem. The line of code that is commented out for the strConsoleAppLocation string field works correctly when I run the application from my workstation. However when the application is deployed the line of code that refers to strConsoleAppLocation path is changed, I get an error on the line of code, " Process1.StartInfo.Arguments = Process_Arguments;".
When the application is deployed, I make certain the executable is located in the directory path: \\server1\\DEV\\Ftest\\Esample.exe.
Here is the code I am referring to;
protected void add_to Web_service()
{
String strConsoleAppLocation = "\\server1\\DEV\\Ftest\\Esample.exe";
String strEncryptedValue = "encrypted";
String strWebServiceurl = "https://test/test1/TWebService";
Process Process1 = new Process();
String Process_Arguments = null;
Process1.StartInfo.UseShellExecute = false;
Process1.StartInfo.FileName = strConsoleAppLocation;
Process1_Arguments = strEncryptedValue + " " + strWebServiceurl + " 798 ";
Process1.StartInfo.Arguments = Process_Arguments;
Process1.Start();
}
Due to what I mentioned above, I have the following questions:
1. Can you tell me what to do to resolve this issue for now?
2. When this application goes to production, can you tell me and/or point me to a reference to display the preferred method
of how the Esample.exe executable should be called?
|
|
|
|
|
Have you even bothered to look at the documentation? You've been at this so long now that I'd have thought that just once, you'd have cracked open MSDN to see what it has to say.
You CANNOT start a remote process using the Process class. This is clearly stated.
If you want to start a remote process, you effectively have three choices:
1. Use the Task Scheduler API
2. Use PsExec.
3. Use WMI (Windows Management Instrumentation).
You now have enough information to figure this out for yourself through the judicious use of Google and documentation.
|
|
|
|
|
I think what you ate trying to do is execute an app on a remote system. Even if your code succeeds, the executable will run locally as a local process. This code must be executed on the server to start your web service, not on the client. You can probably put this as a startup item on the server.
|
|
|
|
|
On top of the other comments, you never said what the error message said. It's kind of important when asking questions about your code.
|
|
|
|
|
I get the error message on the following line of code:
" Process1.StartInfo.Arguments = Process_Arguments;".
|
|
|
|
|
But you didn't say WHAT error you got. That's the important part.
|
|
|
|
|
|
I know this is not a clear question, but this is the situation. I have a windows application which parse some file( i use TPL here).
If i minimize this application and keep idle for more than 30 minutes, then i cannot bring the application back. I can see the minimized icon, but this wont come back even if i do ALT-TAB. This is in windows 7.
Any idea?
My small attempt...
|
|
|
|
|
Can you try this ?
- Right-click on the taskbar and say "Show windows
side by side"
Another option : You may put a timer in your application with this Code:
MessageBox.Show(this.Location.ToString() + "\r\n" + this.Size.ToString() + "\r\n" + this.WindowState.ToString());
this.WindowState = FormWindowState.Normal;
timer1.Enabled = false;
and repost the result here ?
|
|
|
|
|
Is the UI thread blocked? Are you doing som long running operation on the UI thread??
Chances are good one of these two things is what's doing it.
|
|
|
|
|
Is there any reason you sig has enough blank lines to score scrollbars?
Just curious.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Hmmm...it never did before. I'll take a look.
|
|
|
|
|
Another victim of metrosexualisation? I've since noticed a couple of others in the same boat.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
It appears that way!
There were a couple of BR tags under my name that I don't remember placing there.
Anyway, all fixed. Thanks!
|
|
|
|
|
I dont think that the GUI thread is blocked, because using TPL I parse all the files. Then show the result in the grid.
I am minimizing the application after all these operations are completed. That mean app is Idle when i minimize.
If i maximize the app immediately or like after 5. 10 minutes, then i am ok. But after 30-40 minutes i am having issue.
I also use DEV Express grid o show the result.
My small attempt...
|
|
|
|
|
I just told about file parsing, but this behavior may not be related to that. Below is another strange behavior i am seeing.
This is happening only sometimes, which may/may not related to our issue.
Say i have opened any popup window or some applications ( like MS word, IE) from my main form. When I close that popup window/app then the main form will be minimized or some other app will come front. So i had to click the app icon from task bar to bring it back
My small attempt...
|
|
|
|
|
Ditto dave's answer, your UI thread is probably blocked. To resolve this:
Add a BackgroundWorker and create a DoWork handler.
Move your parsing code into there.
Where your parsing code was, call RunWorkerAsync on the BackgroundWorker .
... now your parsing will be done on a background thread so your UI will remain active. You can use ReportProgress with a ProgressChanged handler to pass back info to the UI thread if needed.
|
|
|
|
|
Thanks Dude, instead of BackgroundWorker is use Task and continue with.
Is there any way to check, what went wrong when i got this situation again?
My small attempt...
|
|
|
|
|
Not that I know of, but a good rule for any application that has a UI is to perform potentially long running tasks on another thread so the UI doesn't freeze.
|
|
|
|
|
Thanks Dave, i will get back soon after resolving this issue
My small attempt...
|
|
|
|
|
Hi, so I have multiple textboxes on my c# winform and I am looking for a method to validate each box.
My current implementation works, however I am trying to find a way to expand on it and report which textboxes are not validating successfully.
So say return a string or array where i can search through and then set an errorprovider on them.
This is my validation method.(The method is void and not a bool because i want to return a variable with the failed textboxes)
public bool Successful { get; set; }
public string Information { get; set; }
public void ValidateText(List<object> textbox)
{
foreach (object obj in textbox)
{
if (obj == "")
{
Successful = false;
}
else
{
Successful = true;
}
}
}
and here is my main code
List<object> textbox = new List<object>();
textbox.Add(FirstNTxt.Text);
textbox.Add(LastNTxt.Text);
textbox.Add(CourseTxt.Text);
FormValidation validate = new FormValidation();
validate.ValidateText(textbox);
if(!validate.Successful)
{
MessageBox.Show("error");
}
else
{
}
Any assistance will be appreciated, thanks.
modified 11-Mar-21 21:01pm.
|
|
|
|
|
Your ValidateText will set the Successful to indicate if the last entry in the textbox list is valid or not. All the checking of the earlier entries is lost.
Try something like:
public void ValidateText(List<TextBox> textboxes)
{
Successful = true;
foreach (var tb in textboxes)
{
if (string.IsNullOrEmpty(tb.Text))
{
Successful = false;
}
}
}
and then
List<TextBox> textboxes = new List<TextBox>();
textboxes.Add(FirstNTxt);
textboxes.Add(LastNTxt);
textboxes.Add(CourseTxt);
FormValidation validate = new FormValidation();
validate.ValidateText(textboxes);
if(!validate.Successful)
{
MessageBox.Show("error");
}
else
{
}
Personally, I'd probably make a validation method that operates on one string at a time and then validate and set the errorprovider directly for each TextBox one at a time. (Despite what I showed above, I wouldn't pass the actual TextBox references around. The method should validate the string, possibly returning an error message. The caller (form) passes the .Text and reports the error appropriately.)
|
|
|
|
|
This code well search for all text box in your form and validated it, and it will be better If you Use Tag for Description of Textbox so the user know what he is missing, Plus you avoid typing in the MessageBox something like "No Name" , No Phone" , etc ...
More Over you can tell which TextBox in the form is needed to be validate by checking that Tag if it's Empty or not.
private void CheckTextBox()
{
TxtName.Tag = "First Name";
TxtPhone.Tag = "Phone Number";
foreach (Control control in this.Controls)
{
if (control.GetType().Equals(typeof(TextBox)))
{
if (ValidateText(control.Text))
{
MessageBox.Show(control.Tag.ToString());
MessageBox.Show(control.Name);
}
}
}
}
private bool ValidateText(string text)
{
return text.Equals(string.Empty);
}
P.S :
You can assign the Tag for TextBox by properties Windows during design time.
|
|
|
|
|
Two fantastic suggestions. Thank you so much. Both of these solve the issue I was facing.
Once again, Thanks!
modified 11-Mar-21 21:01pm.
|
|
|
|