|
Glad to help
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Well actually, the call to the default constructor uses the system time as the seed, so your code to initialize with DateTime.Now.Ticks is really not necessary.
Regards
Senthil
|
|
|
|
|
Two small annotations:
1. You don't have to cast the result of the Random.Next method cause it already returns an integer.
2. The maxValue has to be 21 cause the returned integer will be less than maxValue.
www.troschuetz.de
|
|
|
|
|
I have some annotations to Christians posting.
1. You don't have to cast the result of the Random.Next method cause it already returns an integer.
2. The maxValue has to be 21 cause the returned integer is less than maxValue.
3. It doesn't hurt to explicitly initialize the Random object with a seed, although it isn't mandatory as stated by the other poster. Also you should think about using a fixed seed to always generate the same, reproducible random number sequence.
Random rnd = new Random(DateTime.Now.Ticks);
Random rnd = new Random(1);
int randomNumber = rnd.Next(1, 21);
www.troschuetz.de
|
|
|
|
|
Hi, given an Active Directory account as well as a Exchange MailBox can
anyone show me how I link the two together in C# code?
I want to be able to (Given a persons Active Directory Username) retrieve
their details from Exchange.
I know that I must use the msExchMailboxGuid in Active Directory and link it
to the MailboxGUID in Exchange.
When I view the msExchMailBoxGuid property I receive a GUID like
{B8220D80-4788-44D6-83C3-2C421BA7D0BC}
When I call the MailBoxGUID I receive a System.Byte[]. I think that if I
cast the array to a string I might get a match between the two but I am not
sure how to do the ByteArray cast.
Thanks in advance for any ideas
Mark
|
|
|
|
|
Found this by accident, very very strange. OnInit will fire twice in debug mode.
If you put a table into a usercontrol like this:
Note the background attribute, which should be bgcolor, but I typed it incorrectly.. Now add this usercontrol onto a test page. In Debug mode, run the test page. The OnInit event (inside the #region Web Form Designer generated code) will trigger twice. Ie.. load the entire page.. run all your script.. then do it all over again. Place a stop on the OnInit event.. or the Page_Load function to verify. After load, hit refresh on the page itself. You can make a change to the ascx file, ie remove the background attribute, refresh, and the problem disappears.. and vice versa if re-added.
-Traube
|
|
|
|
|
Actually, I just found out that it does the same behavior inside a normal aspx page. Just put the table on the page.. and behavior is replicated. I should have posted this on the IDE discussion forum, sorry I missed it.
-Traube
|
|
|
|
|
Im programmer begginer who program in ANSI C. Im doing research on process migration and therefore would like anyone who knows any site which is related to process migration and checkpointing coded in just c to send it to me
|
|
|
|
|
Here's a handy C program:
if (0 != strcmp("C", "C#"))
throw "You're in the wrong forum."; You might have better luck in the Visual C++[^] forum. C# is a programming language that targets the Common Language Runtime - a completely different monster from C.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi everyone,
I am a newcomer in this vast ocean. I am just a beginner, with a very basic doubt. I have a server and a client program, small basic programs written in C# and in the Microsoft Visual Editor.
My doubt is how to run this application, where in a server is up running and is waiting for the client to connect. Should they be as differnet projects? If I am having them both in the same solution or project, it says more than one entry point due to two Main() in each of them, and I cannot run two projects at the same time if I keep them two seperately.
Waiting for some help in this, as if I accomplish this I have a whole big project to be done in 2 months. So , kindly do help me.
Thank You
Sowmya Mulukutla,
Research Assistant,
Health Informatics Dept,
UAB
|
|
|
|
|
Run the other app from the Windows shell (Windows Explorer/ command prompt)
Regards
Senthil
|
|
|
|
|
Thank you for the help. But when I try to run it from the command line, nothing happens. I mean it just exits and shows the details of the C# compiler. Is there any prespecified path I need to set to execute the code?
For Eg: If ClientTCP is my project, and clientSocket.cs is my code file, then I go to the directory of the project and then do the csc ClientSocket.cs.
I am doing this from the Visual Studio.Net comman prompt only. Kindly do correct me if I am wrong.
Sorry for the trouble,
Sowmya Mulukutla,
Research Assistant,
Health Informatics Dept,
UAB
|
|
|
|
|
Yes, create 2 projects, one for the client and one for the server.
The problem you're seeing when running from command prompt is normal behavior; it runs the static void Main function, executes any code in there, then exits. If you don't want it to exit, put a Console.ReadLine() in the entry function for the console app.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
I tried that too, but no change. Other thing i observed was it is running (as individual projects) from the editor but from the command line it just exits.
I still did not figure out how to make the server and the client talk to each other.
Thank you, anyways,
Sowmya Mulukutla,
Research Assistant,
Health Informatics Dept,
UAB
|
|
|
|
|
Sorry my last mail was just a thank you in the end, anywyas just came out of habit, do not think I gave up eating ur head .
Help needed....,
Sowmya Mulukutla,
Research Assistant,
Health Informatics Dept,
UAB
|
|
|
|
|
Soumya Mulukutla wrote:
I tried that too, but no change. Other thing i observed was it is running (as individual projects) from the editor but from the command line it just exits.
Show me your server code.
Soumya Mulukutla wrote:
I still did not figure out how to make the server and the client talk to each other.
That's a seperate problem. Are you using .NET remoting? Web Services? Message Queue? DCOM? Most likely you'll need to use one of those technologies. If both your client and your server are .NET Windows or .NET Console applications, .NET remoting is probably the right choice for you.
If you need help with one of those topics, or just need general help making your client talk to your server, I suggest you start a new thread, as there's much to be said on any of the remote messaging APIs.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
I'm getting the "Tcp Channel already registered" on an application I'm working on that acts as both a server and a client to be a simple chat client. Hope someone can tell me what the issue with my code is, here's the relevant bits:
---------------------------------------------
//Server
TcpChannel channel = new TcpChannel(8002);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(Hello), "Hi", WellKnownObjectMode.SingleCall);
//Rest of code here
// Client (on button click)
string ipaddr = textBox2.Text;
string port = textBox3.Text;
TcpChannel chan = new TcpChannel(8001);
ChannelServices.RegisterChannel(chan);
Hello obj = (Hello)Activator.GetObject(
typeof(Hello), "tcp://" + ipaddr + ":" + port + "/Hi");
---------------------------------------------------
Thanks in advance,
Matt
|
|
|
|
|
Maybe the process didn't exit properly and is still in memory? Have a look at the running processes in Task Manager.
Regards
Senthil
|
|
|
|
|
Thanks for the reply I've tested this app on the laptop and desktop, and same result on both. All times, the program exits correctly
Anymore ideas?
Many thanks,
Matt
|
|
|
|
|
Yes. The problem is that the application is trying to register a channel on the same port multiple times. That isn't allowed; what you need is to register each channel you have on a different port.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
So simply putting the different port numbers as i have (8001 and 8002) isn't enough?
|
|
|
|
|
There has to be another place in your code that is registering 8001 or 8002. Set debug breakpoints or output some text letting you know when a channel is about to be registered. The only time this message would occur is if a channel has already been registered on that port.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
When you think your program has exited clean, start a command prompt an type:
netstat -a
Look in the output for a "TCP computername:yourportnum..."
If you find an entry for one of your ports, then something is still running.
|
|
|
|
|
Is there any method to append to a string, here's what I'm doing:
<br />
string selectString = "SELECT * FROM table_name WHERE ";<br />
<br />
if(programName.Text != null)<br />
{<br />
}<br />
Any ideas?
|
|
|
|
|
Have you looked at the StringBuilder class?
|
|
|
|