|
Check this link.[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
|
|
That was another good start on a different part of C#, it was clear enough. How about getting a little deeper, can you supply some more?.Lets say trying to write a running program......
Hala
|
|
|
|
|
I don't know in which area of C# programming you are interesting to learn! But it is better by yourself to sign on google and search what first comes in your mind about programming.For any specific question sure you can ask here and CP members with pleasure will answer to you.
Regards.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Thanks.
Ok, this far I can only write and design a program using one form, how can I have more than a form and call them inter-changebly?am kinda struggling with this as of now.
|
|
|
|
|
I have a client that make a RPC to a server, "singlecall", and after the proxy is created that client makes one call back to the object that is on the server.
When called the server object creates a new process and starts cmd.exe. It then makes a query to the local DNS server to check for availability for a node record in a zone. Basically I need to know if a node exists inside a zone.
In development this works great, and after working with this for over a week I am almost sure that I know the deal now. This has to be a security issue. I believe that the new process that is created on the server be the server object is running in to low of privileges to make a call to the DNS server.
I know the RPC is a success because I write line to the console window every time a request is made from the client. The second request from with-in the server object to the new process is the one that is not a success.
How do I set permissions from a situation like this?
Below is my server object. "The one that needs the permissions set"
---------------------------The instantiation is successful
public AFCCDnsManager()
{
Console.WriteLine("Request from client just came in");
}
------------This is the method that needs help. "Works great in development"
public bool CheckIfDomainZoneNodeHasRecords(string server, string zone, string node)
{
Process myProcess = null;
ProcessStartInfo myProcessStartInfo = null;
StreamReader myStreamReader = null;
string cmdFailed = string.Empty;
string dnsCmd = string.Empty;
string output = string.Empty;
try
{
cmdFailed = "DNS Server failed";
//string cmdCompleted = "command completed successfully";
//Command failed: DNS_ERROR_NAME_DOES_NOT_EXIST 9714
//cmd server cmd zone node
//dnscmd afcc-inc-ns1 /enumrecords AFCCINC.COM handlers
dnsCmd = string.Format("dnscmd {0} /enumrecords {1} {2}", server, zone, node);
output = string.Empty;
myProcess = new Process();
myProcessStartInfo =
new ProcessStartInfo("cmd.exe");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.CreateNoWindow = true;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.RedirectStandardInput = true;
myProcessStartInfo.Arguments = dnsCmd;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
myStreamReader = myProcess.StandardOutput;
myProcess.StandardInput.WriteLine(dnsCmd);
char[] blockOfChars = new char[356];
myStreamReader.ReadBlock(blockOfChars, 0, 355);
myStreamReader.Close();
myProcess.Close();
output = new string(blockOfChars);
if (output.ToLower().Contains(cmdFailed.ToLower()))
{
return false;//0
}
else return true;
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
finally
{
myProcess = null;
myProcessStartInfo = null;
//myStreamReader = null;
cmdFailed = string.Empty;
dnsCmd = string.Empty;
output = string.Empty;
}
}
Thank you for your help
Erik
|
|
|
|
|
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I was able to finally get this to nightmare to work.
This is so weird because I would have thought that all I needed to do would be do a .ReadToEnd(); but this just made
the app hang up.
So I have had to do this see saw type of push pull the stream until I get the data that I am looking for.
public bool CheckIfDomainZoneNodeHasRecords(string server, string zone, string node)
{
//
Process myProcess = null;
ProcessStartInfo myProcessStartInfo = null;
StreamReader myStreamReader = null;
string cmdFailed = string.Empty;
string dnsCmd = string.Empty;
StringBuilder output = null;
try
{
cmdFailed = "DNS Server failed";
//string cmdCompleted = "command completed successfully";
//Command failed: DNS_ERROR_NAME_DOES_NOT_EXIST 9714
//cmd server cmd zone node
//dnscmd afcc-inc-ns1 /enumrecords AFCCINC.COM handlers
dnsCmd = string.Format("dnscmd {0} /enumrecords {1} {2}", server, zone, node);
output = new StringBuilder();
myProcess = new Process();
myProcessStartInfo =
new ProcessStartInfo("cmd.exe");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.CreateNoWindow = true;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.RedirectStandardInput = true;
myProcessStartInfo.Arguments = dnsCmd;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
myStreamReader = myProcess.StandardOutput;
do
{
output.Append(myStreamReader.ReadLine() + "\n");
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine(dnsCmd);
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myStreamReader.Close();
myProcess.Close();
Console.WriteLine(output.ToString());
if (output.ToString().ToLower().Contains(cmdFailed.ToLower()))
return false;//0
return true;
}
catch (Exception ex)
{
System.Net.Mail.MailMessage mm = null;
SmtpClient smtp = null;
mm =
new System.Net.Mail.MailMessage
(new System.Net.Mail.MailAddress("problems@afccDnsManager.com"),
new System.Net.Mail.MailAddress("support@afccinc.com"));
//
mm.Subject = "Problems with the AFCC Dns Manager Service";
mm.Body = "Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine;
mm.Body += "Source : " + Environment.NewLine + ex.Source;
smtp = new SmtpClient("smtp.afccinc.com");
smtp.Send(mm);
mm = null;
smtp = null;
//
return true;
}
finally
{
myProcess = null;
myProcessStartInfo = null;
myStreamReader = null;
cmdFailed = string.Empty;
dnsCmd = string.Empty;
output = null;
}
}
Any suggestion?
http://storefrontdoors.net
Erik
modified on Thursday, April 9, 2009 5:19 PM
|
|
|
|
|
Hi, I am trying to append text to a textbox in a form after clicking a button in another form. How do I access the textbox from the button click method?
Thank you.
|
|
|
|
|
Write a function in Form2 that can be called by Form1. The function should accept a string, and set the appropriate control that that string value.
You may now go forth, and write code.
"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
|
|
|
|
|
Thank you! Totally forgot about that.
|
|
|
|
|
Im planning that when the form loads it is invisible. So what i did was in the constructor of the FORM I called the form or set the form to hide by setting the VISIBLE property to false or called the hide function. It doesnt work.. so I used the form load event, and i set the properties and or function there and it doesnt work.. so i used the form shown event, it worked but the problem is, the form shows then dissappears and its kinda look ugly that way.. what i want is that when executed the form is invisible without a trace.
|
|
|
|
|
Set the opacity to 0 in the form properties.
"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
|
|
|
|
|
It's a problem in your calling code, not the form itself. You can create a form by calling it's constructor, everything will happen then (if written properly) but it will not be visible.
|
|
|
|
|
if you want your form invisible, why use form? i mean how about just create an object that hold all information (field, method, properties) of your "invisible form".
hope it helps.
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
The "why" is irrelevant. If you can't help the guy, refrain from posting.
"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
|
|
|
|
|
Just make a suggestion. If you don't need a visual object why you use that?. You can create an object substantially similar of "invisible form" and you don't have to set Visible property to false.
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
You don't see to get it. The original poster asked how to do something - NOT for alternatives to what he was doing or opinions about his coding. Answering someone's question AS POSTED is a lot more important that trying to prove you're clever (which you aren't).
"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
|
|
|
|
|
so you are clever enough with your answer : 'Set the opacity to 0 in the form properties.'
don't be rude dude.
John Simmons / outlaw programmer wrote: a lot more important that trying to prove you're clever (which you aren't).
I don't need to prove that I'm clever or not. I know you are MVP in CP, IMO nothing special with your knowledge. In this forum, peoples can share all possible answer to help others as you do with writing all your articles. aren't you?
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
John Simmons / outlaw programmer wrote: Answering someone's question AS POSTED is a lot more important that trying to prove you're clever
Many people don't know what to ask for, how to ask for it, or where to ask for it. If you only ever answer exactly what people ask for, you often can not give them the answer that they want, or the answer that they need.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I agree with you dude.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Guffa wrote: Many people don't know what to ask for, how to ask for it, or where to ask for it
If a person's communication skills aren't adequate, maybe they should learn better English. That *is* the language used on this site.
Guffa wrote: If you only ever answer exactly what people ask for, you often can not give them the answer that they want, or the answer that they need.
How could that guys question have been interpreted as "give me an alternative". He wanted to set the form to be invisible when it started up. I gave him the solution to *that* question. I don't care why he wants to do it.
I do some pretty whacked out stuff myself (like most of us have), and I personally don't like being quizzed as to my motives, or have some nimrod in a foreign country second-guessing me - I just want an answer to the question I posted. If you can't get your pointed little heads around that concept, then please don't answer my questions.
In any case, this conversation doesn't belong in this forum.
"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
|
|
|
|
|
In MSDN guide convert array bytes to string, here code: Encoding.UTF8.GetString(byte[] bytes) VS2005 doesn't support convert one byte to string.
Anybody can I help me? or for example how to convert one byte to string. Although, may be use to Convert.ToString(byte) is correct, but I don't think so. Except, differently another way
Thank one so much!!!!
|
|
|
|
|
Encoding.UTF8.GetString(byte[] bytes) is working. did you try the method Tostring();
|
|
|
|