|
I am just guessing here. Is the listener fully disconnected from the serve before or after sneding the FOAD message to the client? Try either removing the listener side of things BEFORE the disconnect message or WAITING for a disconnect from the client. I prefer teh first of the two.
If you have disconnect from the server end, then there is no way that the client can send you any EOS messages which is what I think you are getting.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I'm not quite sure how to do what you mean, thought I had done that by removing and closing the socket. Could you explain or give an example?
Also what does FOAD and EOS mean?
I'm still a little wet behind the ears here since I'm teaching myself this, so I apologize for the beginner questions.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
When you create the listener, you attach it to a listener event handler these need to be removed as well as releaseing the handle to the listener.
[FOAD - .... And Die, EOS - End of Stream]
[added]
These are not beginer questions, you're doing okay!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
But if I were to release the listener wouldn't that mean that no more people could connect to the server?
Even if I did it temporarily wouldn't that dead period block people off from connecting?
Should have gotten the FOAD meaning though
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Not having the /exact/ code you are using, makes this an answer in theory.
When you receive the connection, you validate the session and give the session listener a handler that will process the events:
listener.DataReceived += new System.EventHandler(server_DataReceived);
When the sesseion is being disconnected, you need to disconnect the lsitener:
listener.DataReceived -= new System.EventHandler(server_DataReceived);
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
|
Hi Friends,
I'm Harry actually i'm fresher student in software engeenring line and i'm doing aa activity . I created a login form in Microsoft Visual Studio 2005 and I'm trying to store user id and password on back end. And I'm using this code for this purpose but every time it shows an error and error is when every time i fill the user id and pasword and i just click on login button and message box appear with meesage user id and password is wrong. plz help me in thsi activity. down here the code plz check it out the error .
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=DEVILINSIDE\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True");
SqlDataAdapter da = new SqlDataAdapter("select * from loginform", con);
con.Open();
SqlCommandBuilder cmb = new SqlCommandBuilder(da);
DataSet ds = new DataSet("dataset");
da.Fill(ds, "loginform");
DataTable dt = new DataTable();
dt = ds.Tables["loginform"];
foreach (DataRow dr in ds.Tables["loginform"].Rows)
{
if (textBox1.Text == dr[0].ToString() && textBox2.Text == dr[1].ToString())
{
welcome w = new welcome();
w.Show();
}
else
{
MessageBox.Show("Invalid User Name or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox2.Text = "";
}
}
|
|
|
|
|
First of all you are doing this the Wrong way
First Create a Stored Procedure that does this
Create Procedure prclogin_check
(
@User_name varchar(20),
@U_Password varchar(23),
@Results int Output
)
IF EXISTS (Select * from User_Table
where User_name =@User_name and U_Password = @U_Password)
Set @Results =1
And after you are done with this , you have to do the Following in your C# Code
using System.Data.SqlClient;
String strcon = "User id = sa;Password= topman;Server=myServer;Database=MyDB";
SqlConnection con = new SqlConnection(strcon);
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandTimeout = 0;
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.Connection = con;
cmdselect.CommandText = "prclogin_check";
cmdselect.Parameters.Add("@Results",SqlDbType.Int,4);
cmdselect.Parameters["@Results"].Direction = ParameterDirection.Output;
int Res;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
Res = (int)cmdselect.Parameters["@Results"].Value;
con.Close();
}
catch (SqlException e)
{
MessageBox.Show(e.Message);
}using System.Data.SqlClient;
String strcon = "User id = sa;Password= topman;Server=myServer;Database=MyDB";
SqlConnection con = new SqlConnection(strcon);
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandTimeout = 0;
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.Connection = con;
cmdselect.CommandText = "prclogin_check";
cmdselect.Parameters.Add("@Results",SqlDbType.Int,4);
cmdselect.Parameters["@Results"].Direction = ParameterDirection.Output;
int Res;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
Res = (int)cmdselect.Parameters["@Results"].Value;
con.Close();
}
catch (SqlException e)
{
MessageBox.Show(e.Message);
}
And in your Business logic or in your Form you can create a Function that will test if the Count of Records is greater than 0,if its less than that , then its invalid login
Hope this Helps
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Can anyone provide me with a code example of how to use a datetimepicker cell in datagridview where in the
datetimepicker column i can set the value of any cell to null or to any datetime according to my choice. And the format of the datetimepicker cell should be dd MMM yyyy. I checked a lot of examples in the forums including articles by Nils Jonsson, Pham Minh Tri and Claudio Grazioli but none of them works when the DGV is databound. It works till u can select a date in a blank cell and save it. But when u try to delete an existing date from a cell it generates error saying 'Formatted value of the cell has a wrong type'. There's no way I can set a null value in a databound cell. I'm fed up of this. Plz help.
|
|
|
|
|
Hi,
How to find whether horizontal scroll bar is moved right or left?
If its moved right then some code need to get execute and vice versa.
Thanks...
Reg,
Subbu
|
|
|
|
|
Two events to look at:
private void hsc_Scroll(object sender, ScrollEventArgs e) {
}
private void hsc_ValueChanged(object sender, EventArgs e)
{
}
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
This is the 5th version of the same question.
|
|
|
|
|
Hi, i would like to explain my problem. I want to see the code when my applcation generate an exception.
I create a simple application that crash when a button is pressed:
private void button1_Click(object sender, EventArgs e)
{
Int32 Text;
Object obj= null;
Text= (Int32)obj;
}
This code generate a NullReferenceException when it try to make a cast of "obj".
Now, i run .exe file on a pc with only VS2008,when i click the button,jitdebugger start and ask me where is the file .cs.
My questions are:
Why the jitdebugger ask me where is the .cs file?
If i open module page (ctrl+alt+u) i see my file .exe with symbols loaded, but i can see the c# code.
Help me please.
Thank you, have a nice day
bye bye
|
|
|
|
|
frommi wrote: Why the jitdebugger ask me where is the .cs file?
Did you actually create a deployment app or are you just copying the .exe from the bin directory to another computer? This will not work.
As for the error, you might want to try the following.
Text = Convert.ToInt32(obj);
This will run without creating an error.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Kwagga wrote: just copying the .exe from the bin directory to another computer? This will not work.
Sure it will. Debugging won't, but the app will (unless it throws an Exception ).
|
|
|
|
|
frommi wrote: Why the jitdebugger ask me where is the .cs file?
There is no global exception handler in your application. Thus, you're asked whether or not you want to debug the application. The debugger will ask for the code-files to point out where the exception occurred.
frommi wrote: If i open module page (ctrl+alt+u) i see my file .exe with symbols loaded, but i can see the c# code.
Symbols are provided by the .pdb file, and you'll only see the C# code when the debugger can find the appropriate source-code.
|
|
|
|
|
well, i create the Release version of my simple application and i copy all Realese folder, it contains:
CrashDebug.exe
CrashDebug.exe.config
CrashDebug.pdb
CrashDebug.vshost.exe
CrashDebug.vshost.exe.config
CrashDebug.vshost.exe.manifest
and i set in .config file
configuration
system.windows.forms jitDebugging="true"
configuration
The error is created for start the debug and see the code.
But i can't see that.
|
|
|
|
|
You can't see the code, because it's not physically there. It knows the name of the files by looking at the "CrashDebug.pdb" file. There it finds the name of your .cs file, and asks for it.
What were you expecting to see?
|
|
|
|
|
I expected to see the line code, like when i run application directly form visual studio IDE.
You are sure that is impossible to see the native code when it's crush and the JITdebug run for resolve the problem?
|
|
|
|
|
It's not impossible. You'd need the source-code against which the executable was compiled, otherwise the addresses in the pdb-file[^] will point to the wrong line. It's as easy as copying the source-files to the system where the exception is occurring.
That is, if that is your intention.
If you're wondering whether someone can decompile your code and look at the internals - then you're right. If it's your intention to stop that, then start with not distributing the pdb-file and check out the different code-obfuscators for .NET
|
|
|
|
|
hey guys.. i'm trying to make a comic strip creator application in c#.. it involves character creation so that the users can customize the characters that they want to put in their comic strip.. just imagine the character/avatar creator that we see in the internet.. that's what i'm trying to do.. my problem is that i don't know what approach am i going to use for this part of my program.. i tried using picture box and merging the combination that was chosen as a single image but i can't do it.. and i think that approach was wrong too.. this is my first time to make an application that involves image manipulation so i really need suggestions on how to do this..
and also, is it possible to insert images using the paint event??
|
|
|
|
|
strife19 wrote: and also, is it possible to insert images using the paint event??
Yes, I would recommend using the paint event and a panel.
So I am assuming you have a load of images (for each part of the character) that you want to effectively place on top of each other?
Create a number of Class Level Image Objects...
Image Hair;
Image Face;
Image Body;
Set the Images with whatever method you want, example...
Hair = ImageListHair.Images[2];
PanelMain.Invalidate();
Then in paint event draw them on the panel...
void PanelMainPaint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(Body, xPos, yPos, width, height);
}
...Hope that makes sense?
This is a very basic idea, you could, and probably should, have a Character class with properties for each of the different body parts and a method that draws the character by taking a Graphics object as a parameter.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
thank you for your suggestion.. i will try this approach right away and post whatever the outcome is..
|
|
|
|
|
Hi
I need to capture screenshots from DirectX games. I am using this code but sometimes I get totally blank images or the image of the desktop (but the game is open)
int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));
bmpScreenShot.Save("test.jpg", ImageFormat.Jpeg);
I really need help.
Thanks.
|
|
|
|
|