|
I'm using class Net.Socket to establish internet connection. Everything is OK, but I can't close the connection.
Methods .ShutDown(...) and .Close() do not help me - the connection is still alive, after calling these methods.
My code:
/////////////////////////////////////////////
_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress address = hosts.AddressList[0];
IPEndPoint ipep = new IPEndPoint(address, port);
try
{
_sock.Connect(ipep);
}
catch(Exception sockex)//(SocketException sockex)
{
}
// CLOSING
_sock.Blocking = false;
_sock.Shutdown(SocketShutdown.Both);
_sock.Close();
|
|
|
|
|
I would think Close should. Did you try Disconnect?
Rather than swallowing exceptions, you might rather use a finally block:
try
{
_sock.Connect(...);
}
finally
{
_sock.Close();
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
|
Hello Everyone,
I am wondering if it is possible to use F9, F10, F11, & F12 as a shortcut key in my web application. I know that IE reserves some of them, but the client would find it useful if we could apply them for the application purpose rather than using Alt+Character.
Has anyone accomplished this without using a 3rd party add-in product?
Thanks for the thoughts-in advance.
SD
|
|
|
|
|
Hey,
i was just wondering, how do i make a menubar like the one in Skype ? (http://www.skype.com/i/screenshots/step1_windows.png[^] - The top one with icons)
It seems like it is just regular buttons, they have used which gets the outline when the mouse is moved over.
But i cant find out how to remove the outline from the buttons when the mouse is not over.
The 3 styles i have all have a outline (standard in .Net 2.0), and doesnt look like the ones in Skype.
Also is the Seperator which is used a standard item ? or is it something they have made themself ?
Martin
|
|
|
|
|
Hmm ...
Actually it is not only Skype that have that type of buttons ... also Internet Explorer, Outlook and more uses that type of buttons...
It is just like normal buttons with a Image attached but they dont have the outline, only when the mouse moves over...
I guess they are probably already a part of the .NET 2.0 Framework ...
But how are they made ? what are they called ? i simply cant find out ...
Can anyone help me ?
What should i look for, for creating buttons like that ?
|
|
|
|
|
Hi everybody!
I've got a problem: (C# 2005)
I'm writing an applitcation that menage a database. I want to use the timestamp method to make the update to the database. I've alreay added to each relation in my database a column with a timestamp value. I know i must modify the text of the update command in the table adapter but i dont know how...
please help me!
thank you in advance
Enrico
VentoEngine corp.
Program your life ^^
|
|
|
|
|
I installed VS2005 very recently. Where is the DataAdapter( all types sql,ole) object which usually shows up under the Data tab in the ToolBox in VS2005. Any help or links would be greatly appreciated.
Thanks
VPMahank.
|
|
|
|
|
I m using ASP.net with C#.I want to dispaly a message box just like we do "Alert('this is message')" in javascript.But i want to show such a message box or dialogue box in asp.net with C#.what should i do because its not a windows form
|
|
|
|
|
Do you want to show the message box on the browser? If so, alert('message') does it. Remember that JavaScript is case sensitive so it needs to be alert not Alert. If you want to show it on the server, then you can't because it would freeze the server until someone clicked OK.
Regards,
Alvaro
|
|
|
|
|
Maybe this can help
<br />
MessageBox.Show("Error message", "Name Entry Error", MessageBoxButtons.OK,MessageBoxIcon.Exclamation);<br />
VentoEngine corp.
Program your life ^^
|
|
|
|
|
Won't work in an ASP.NET app. MessageBox is only part of the Windows.Forms namespace.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
You can write code in java script and use 'Registerstartupscript' for implementing that script.
lucky
|
|
|
|
|
I have created my own composite control, a "Color Check Box". I derived from UserControl and added a Picture Box (ColorCheckBoxButton) and a Label (ColoeCheckBoxLabel). I want the composite control to expose the Text property. The UserControl class already has a Text property, so I figure I must override it with the following code:
[Category("Appearance")]<br />
public override String Text<br />
{<br />
get { return ColorCheckBoxLabel.Text; }<br />
set { ColorCheckBoxLabel.Text = value; }<br />
}
Programitically this works and I can assign the Text property when I use the composite control. However, the Text property of the compiste control does not seem to be exposed in the Properties window of the VS designer when I user the composite control from the Toolbox. There appears to be NO Text property.
What am I doing wrong?
Thanks!
Mark Mokris
|
|
|
|
|
The Text property of the UserControl class has its Browsable attribute set to false , so you will need to add it (however this will create some serialization issues, so you will also need to add a DesignerSerializationVisibility attribute, set to Visible )...
[
Category("Appearance"),
Browsable(true),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)
]
public override String Text
{
get { return ColorCheckBoxLabel.Text; }
set { ColorCheckBoxLabel.Text = value; }
}
Cheers,
Will H
-- modified at 11:15 Monday 30th January, 2006
|
|
|
|
|
Thanks Wil! That worked! How would I ever have found that?
One more question. How do I change the Text property in the parent class (UserControl) now that I have overridden the Text Accessor method. If I do the following, it results in a stack overflow, because the parent accessor method is called recursively:
[Category("Appearance")]<br />
[Browsable(true)]<br />
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]<br />
public override String Text<br />
{<br />
get { return ColorCheckBoxLabel.Text; }<br />
set { ColorCheckBoxLabel.Text = value; this.Text = value;}<br />
}
|
|
|
|
|
MarkMokris wrote:
One more question. How do I change the Text property in the parent class (UserControl) now that I have overridden the Text Accessor method. If I do the following, it results in a stack overflow, because the parent accessor method is called recursively:
Use base.Text instead of this.Text to pass the value to the parent class (this should work).
Glad I could help
Cheers,
Will H
|
|
|
|
|
How is MSIL code and .exe file is generated?
sowjanyakumar
|
|
|
|
|
What? I don't get your question. Do you mean something like this?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
It's an over-simplified explanation...But, when you compile your C# code, it's gets turned into MSIL code in the .EXE file. When you launch the .EXE, the MSIL code is then compiled by the Jist-In_time compiler in the .NET Framework into native machine code for the processor it's running on.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
can anybody help me in serialization of a ListDictoinary to XML, since it doesn't implement the ISerializable-Attribute I'm still searching the whole www to find ideas but no one seems to face this problem.
I need to reconstruct the Dictionary with its special attributes so i can't use a arraylist.
thx
|
|
|
|
|
Hi. I tryied to test dialog (windows form) inside MSVS C#, but Ctrl+T or "Format"/"Test dialog" functions were disabled. Could anybody tell me why? I noticed, that all items from the "Dialog editor" toolbox were disabled.
Thank you.
B.
|
|
|
|
|
Hi
i am working in c# with infragistics
In c# windows applicaion, I will be passing data from textbox..such that
for example:i havE 3 texboxes labeled
name:
age:
salary:....
Now name is the parent and age and salary r the child..so if i pass data in
the appropriate textbox..It should be added in the ultrawintree.......such that
name(parent) should show up on the root node of the tree. and age and
salary(child) should show up under the root node.
so now when I run this program, as it reads a xml schema and creates a xml file.. now when I clicked the ADD button, it checks for the xml file and each textbox
is binded to the xml elements..so that the data which is passed in the xml file willbe added in the xml..
now for example i gave john,22,1800 for name,age and salary respectively and again john,45,3800
so it should be shown in teh tree as follows tht john under john both ages and salary should be shown
ie like
parent(name) : john
child(age) : 22 45
child(salary): 1800 3800
but i am getting teh result as follows..
john
22
1800 and again
john
45
3800 seperately.... so please tell me how to do it.
here is my coding part
//FUNCTION FOR ADDINGNODES
private void AddNode(string ParentNAME, string AGE, string SALARY)
{
//add parent node
Infragistics.Win.UltraWinTree.UltraTreeNode parentNAMEnode = new Infragistics.Win.UltraWinTree.UltraTreeNode();
Infragistics.Win.UltraWinTree.UltraTreeNode AGEnode = new Infragistics.Win.UltraWinTree.UltraTreeNode();
Infragistics.Win.UltraWinTree.UltraTreeNode SALARYnode = new Infragistics.Win.UltraWinTree.UltraTreeNode();
//add parent node
parentNAME.Text = ParentNAME;
//other nodes
AGEnode.Text = AGE;
SALARYnode.Text = SALARY;
//add childnodes to parent
parentNAMEnode.Nodes.Add(AGEnode);
parentNAMEnode.Nodes.Add(SALARYnode);
parentNAMEnode.Expanded = true;
//add teh nodes to teh ultratree
ultraTree1.Nodes.Add(parentNAMEnode);
}
//ADD button
private void button1_Click(object sender, System.EventArgs e)
{
DataSet dataSet = new DataSet();
// Read the existing xml
dataSet.ReadXml("..\\..\\resultdata.xml");
//PARENTName TEXTBOX
string strParentNAME = txtParentNAME.Text;
//AGE Text box----int type
string strAGE = txtAGE.Text;
int intAGE;
if (!strAGE.Equals(string.Empty)) // check to make sure the user entered something
intAGE = Convert.ToInt32(strAGE);
//SALARY Text box----int type
string strSALARY = txtSALARY.Text;
int intSALARY;
if (!strSALARY.Equals(string.Empty)) // check to make sure the user entered something
intSALARY = Convert.ToInt32(strSALARY);
//create a new row
DataRow newrow;
newrow = dataSet.Tables[0].NewRow();
// add new row.
newrow["ParentNAME"] = strParentNAME;
newrow["AGE"] = strAGE;
newrow["SALARY"] = strSALARY;
AddNode(strParentNAME,strAGE,strSALARY);
//add the row to the dataset
dataSet.Tables[0].Rows.Add(newrow);
//write the data to a xml file
dataSet.WriteXml("..\\..\\resultdata.xml", XmlWriteMode.WriteSchema);
dataSet.AcceptChanges();
MessageBox.Show("Saved");
}
//form load
private void Form1_Load(object sender, System.EventArgs e)
{
DataSet dataSet = new DataSet();
//read the schema
dataSet.ReadXmlSchema("..\\..\\Menu.xsd");
dataSet.WriteXml("..\\..\\resultdata.xml",XmlWriteMode.WriteSchema);
}
please help me to do this
|
|
|
|
|
how do i embed or put an icon image in a binary file using C#????
|
|
|
|
|
Just a quick question. Is there an easy way to see if an object implements a particular interface? At the moment I am casting it and looking for an error Is there something like implements(object,interface) bool
Definitely a PEBCAK! (Problem Exists Between Keyboard And Chair) www.FruitBatInShades.com
|
|
|
|