|
Thank you!
I changed "localhost" to "ExchangeServer" (our local mail server) and it worked.
But if the application is running on a computer outside our network, the SMTP host will be different.
So is there a way to determine the SMTP host address/name of the current computer/user?
|
|
|
|
|
If the Exchange server is internet accessible (a fully qualified domain name), then just use that instead so that if you're deploying outside of your LAN, it can still be reached.
If not, then you might need to allow for user configuration to specify the SMTP server name or address.
|
|
|
|
|
Ah ok...
But it's not possible to get the hostname/address from the SMTP server in C#?
|
|
|
|
|
Hi all,
I have a windows service, and I handle three events there like Timer, two port listeners.
OnStop() of the service I want to kill/stop those three events. So, simply I catch the exception as follows.
protected override void OnStop()
{
try
{
TimerTicker.Stop();
LstOne.Stop();
LstTwo.Stop();
}
catch(Exception ex)
{
EventLog.WriteEntry(ex.Source,ex.Message);
}
}
Ok, here is my question. Say the TimerTicker found an exception, OnStop() exit from there and next two event dead, I mean not stopped. How should I handle.
Using separate three function to do this, seems to me odd.
I appreciate your help all the time...
Eranga
|
|
|
|
|
With Seprate try catch block inside one method.
Regards,
Vythees
Miles to go before sleep...
|
|
|
|
|
Thanks for the replay.
Something like this.
try {
}
catch(correct_exception_for_timer) {
}
catch(correct_exception_for_listener) {
}
catch(correct_exception_for_listener_two) {
}
Ok, say on the timer I got the exception. Is that remainders are execution. Like LstOne.Stop() is executed?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
No. He means like this:
try
{
timer.Stop();
}
catch (Exception ex1)
{
}
try
{
FirstOne.Stop();
}
catch (Exception ex2)
{
}
try
{
SecondOne.Stop();
}
catch (Exception ex2)
{
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Ok, I got the point. Is that the much better way to do it?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
It's the *only* way to do it if you want to try stopping all of the objects regardless of whether or not one or more of the others stop.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Logically yes, but the code can be made better by using a more functional approach.
Action [] stopActions = { TimerTicker.Stop, LstOne.Stop, LstTwo.Stop };
foreach(Action action in stopActions)
{
try
{
action();
}
catch(Exception ex)
{
EventLog.WriteEntry(ex.Source, ex.Message);
}
}
|
|
|
|
|
Write seprate methods like this..
<br />
<br />
public void StopTimer(bool suppressEx)<br />
{<br />
try { <br />
timer.Stop();<br />
}<br />
catch (Exception ex)<br />
{ <br />
if( suppressEx == false)<br />
throw ex;<br />
}<br />
<br />
In your Stop method you can call like this...
public void Stop()
{
StopTimer(false);
StopFirstPort(false);
......
}
Choose the way you like...
Regards,
Vythees
Miles to go before sleep...
|
|
|
|
|
You can wrap each method in a delegate, pack the delegates in an array and then loop over the array. Something like
Action [] stopActions = { TimerTicker.Stop, LstOne.Stop, LstTwo.Stop };
foreach(Action action in stopActions)
{
try
{
action();
}
catch(Exception ex)
{
EventLog.WriteEntry(ex.Source, ex.Message);
}
}
|
|
|
|
|
Thanks for all replays.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi,
I need to know how I can display bytes received/sent (maybe using WMI), if I have more than one connections open simultaneously, say a GPRS dialUP, and a LAN (or even two LANs), and need to get explicitly, of which connection the information belongs to.
Also I needed to ask whether the bytes received/sent info is what actually is sent over the transmission medium(ofcourse in terms of packets and bytes), i.e compressed and encrypted with headers, or if it represents the actual size of the packet(i.e just the data + headers).
|
|
|
|
|
WMI wont tell you that, you need a network sniffer. Look here on CP for a WinPCap wrapper for .NET.
|
|
|
|
|
Hi !
Yeah thanks leppie, i have been searching for this in wmi, but I couldn't find much on what I needed to do. I guess, sniffing would be the right choice then!
Thanks alot!
|
|
|
|
|
I need to replace this caracter " to nothing in my database but its not work.
her som code.
SqlCommand cmd1 = new SqlCommand("update c5 set name= replace(name,'"',''), conn);
but its make error on visual studio but in micrsoft Sql Server managment its work fine.
Error:
Error 2 Too many characters in character literal
) expected
; expected
; expected
Hope i can help me..
|
|
|
|
|
Stop and think about what you're telling the compiler. How does it work out that " is meant to be a quote within a string, and not the end of a string ?
\" is a quote within a string, or "" if you put @ at the front, and \ then means \.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hello,
how can i launch multiple exe file using only one process
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
Maybe split the parent process into several threads and launch your child processes from there?
|
|
|
|
|
System.Diagnotics.Process.Start("@C:\\Process1.exe");
System.Diagnotics.Process.Start("@C:\\Process2.exe");
System.Diagnotics.Process.Start("@C:\\Process3.exe");
System.Diagnotics.Process.Start("@C:\\Process4.exe");
System.Diagnotics.Process.Start("@C:\\Process5.exe");
Sure you could have an array of strings, and iterate through them, or something?
-= Reelix =-
|
|
|
|
|
You can load your exe's in diffrent AppDomain under one process.
The above solution is only applicable, if your exe all are .NEt compatible.
Regards,
Vythees
Miles to go before sleep...
|
|
|
|
|
With only one process and process.start?
string batchFilePath = @"C:\mybatch.bat";
File.WriteAllText(batchFilePath, string.Format("start process1.exe{0}start process2.exe{0}start process3.exe{0}start process4.exe", Environment.NewLine));
using (Process batchProcess = new Process())
{
batchProcess.StartInfo.FileName = batchFilePath;
batchProcess.Start();
}
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
How i can change the Tab form?i would do a tab control but i would change the tab form and i would do the same of visual studio tab.
|
|
|
|
|
Do you mean you want to change how a tab looks ? You need to owner draw it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|