|
NO .. I tried with port 7891 and with 4545 .. if you have any other suggestions ... try on you computer you'll get the same result
Lazar Mihai
Highschool student
|
|
|
|
|
I extended your class so I could see what was happening. When I tried the other ports you mentioned I got an exception to say that it wasn't connected. When I tried port 21 my application returned:
32 32 30 20 4d 69 63 72 : 220 Micr
6f 73 6f 66 74 20 46 54 : osof t FT
50 20 53 65 72 76 69 63 : P Se rvic
65 d a 0 0 0 0 0 : e
public class MainC
{
private static byte[] buffer = new byte[1024];
public static void Main()
{
IPEndPoint ipe = new IPEndPoint( IPAddress.Parse( "127.0.0.1"),21);
Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
s.Connect(ipe );
if( s.Connected )
{
Console.WriteLine( " I have a socket that didn't connect to nothing ");
Console.WriteLine(" But it's status is connected ");
Console.WriteLine(" Uraaa !");
}
else
{
Console.WriteLine("Not Connected");
}
int result = s.Receive(buffer, 1024, SocketFlags.Peek);
Console.WriteLine("Received {0} bytes", result);
for(int i=0; i<result; i+=8)
{
Console.WriteLine("{0:x} {1:x} {2:x} {3:x} {4:x} {5:x} {6:x} {7:x} : {8}{9}{10}{11} {12}{13}{14}{15}",
buffer[i], buffer[i+1], buffer[i+2], buffer[i+3],
buffer[i+4], buffer[i+5], buffer[i+6], buffer[i+7],
(char)buffer[i], (char)buffer[i+1], (char)buffer[i+2], (char)buffer[i+3],
(char)buffer[i+4], (char)buffer[i+5], (char)buffer[i+6], (char)buffer[i+7]
);
}
Console.ReadLine();
}
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Don't connect to local host ... on local hosts it works ...
I want on other ip addresses not to work ...
Lazar Mihai
Highschool student
|
|
|
|
|
|
You are right .. thanks I think I 've fixed the bug
Lazar Mihai
Highschool student
|
|
|
|
|
|
Cool ... telnet worked .. why if the address doesn't exist on the LAN .. ?
Lazar Mihai
Highschool student
|
|
|
|
|
Hi I am converting a wmf(drawing file) file in to hexa decimal Format here I am able to convert the data from WMF file to hexadecimal but the problem is the characters
(A,B,C,D,E,F)in converted Hexa decimal format are coming in Small Case letters which should be in capital Letters can any of u help in getting the characters in to Capitals
I am using the following code to convert.
uint uiDecimal = 0;
uiDecimal=checked((uint)System.Convert.ToUInt32(shapeDiagramData[i]));
string str;
str = String.Format("{0:x2}",uiDecimal);
sw.Write("{0}", str);
Shashidhar.
|
|
|
|
|
|
I am getting errors when I try to insert data into my database. I dont have any problems viewing the database. I think it is a problem with my insert statement:
oleDbInsertCommand1.CommandText="INSERT INTO UserTable(Username,Password) VALUES('@NewUserTextBox.Text','@NewPasswordTextBox.Text')";
oleDbInsertCommand1.ExecuteNonQuery();
I have even tried it without the @ and other ways. This is the error I get below.
System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
|
|
|
|
|
You can do it this way, but it's susceptible to SQL injection attacks (a common way that malicious users can attack a web site and destroy databases):
oleDbInsertCommand1.CommandText="INSERT INTO UserTable(Username,Password) VALUES('" + NewUserTextBox.Text + "','" + NewPasswordTextBox.Text + "')";
Instead you should set up an oleDbParameter collection and attach it to the oleDBInsertCommand1 object. You'd populate the paramters from the two textboxes (NewUserTextBox and NewPasswordTextBox). If you named these parameters '@NewUser' and '@NewPassword' respectively, then you'd code the CommandText as follows (notice that there are no single quotes here):
oleDbInsertCommand1.CommandText="INSERT INTO UserTable(Username,Password) VALUES(@NewUser, @NewPassword)";
This is the secure, recommended best-practice solution. There is more help on parameter collections in the Visual Studio on-line help.
|
|
|
|
|
I need to know how to re-draw graphics on my forms when the forms are minimized or lose focus. I know there are an Update() and Invalidate() method but when I use them they don't work. I need to know where to put them actually.
I already know that the OnPaint() method is called when the form loses focus and graphics need to be drawn. The reason i don't want to go that route is because I am using a button control that when pressed, there are counters that will change the coordinates of the graphic shape. This means I would have to save the current state or coordinates after each time the button is pressed and it would be a hassle to pass all of this to the OnPaint() method, even though it could be done.
I just need a simple way to redraw my graphics in the forms.
|
|
|
|
|
save all the graphics in an ArrayList
make some class like Elipse , Arc.. etc
OnPaint()
foreach ( drawing in myDrawings )
{
drawing.Draw( e.Grahics ) ;
}
Lazar Mihai
Highschool student
|
|
|
|
|
I have a program that includes 2 splash screens. They both load correctly but the one that has a flash movie in it will just load and not play the movie. I think it is because I am using a Thread.Sleep(), that will just load the form but not execute any functions. If I load the flash form without threading the movie will play, so I know it is not an playback issue. This is a sample of the code in the Main() function.
LogoSplash logo=new LogoSplash(); //This works good
logo.Show();
Application.DoEvents();
Thread.Sleep(5000);
logo.Close();
FlashSplash flash=new SplashScreen(); //This is where i have issues
flash.Show();
Application.DoEvents();
Thread.Sleep(10000); //will execute, but not play movie
flash.Close();
Application.Run(new ParentForm());
I just want the flash splash form to load and play for 10 seconds, terminate and then load the main form.
If there is another route please, can anyone lead me in that direction.
|
|
|
|
|
You coud try not putting the thread to sleep .. and use a timer inside the flash splash screen..
and maybe do something like
Application.Run( new SpashScreen() );
// when the 10 seconds are up
inside the tick counter .. this.Close();
then the ParentForm() is going to appear ...
Lazar Mihai
Highschool student
|
|
|
|
|
Can any one help me out how to write the code for addin in C# which creates a button on command bar and on click of that button entire document data shuld be saved to database.(not only word but this should work for every office application ppt,xls,doc..it shuld be generic to office applications)
text selection shuld be hidden from user how?
how to add customdocument property of an office application thru C#? this can be done i VB.NET but it has some issues with C# plz help me out
|
|
|
|
|
use Extensiblity Projects - Shared Add-in to reach that.
|
|
|
|
|
hi
how can i load a mesh with items which are linked together and apply transormation to them using managed directx
thanks for help
|
|
|
|
|
Hi every body
I Wrote a calendar class that have a collection of holidays as an ArrayList. This
collection is a property of my custom control that I want Add some objects of
Holiday class to it at design time.I want to customize the .NET collection editor
to add my Holiday class instances instead of object type.Please help me.
My holiday class is very simple as follow :
public class Holiday
{
private int month;
private int day;
private string reason;
public Holiday(int month,int day,int reason)
{...}
//Properties
public int Month
{...}
public int Day
{...}
public string Reason
{...}
}
I read some articles is code project but they were very complicated.Please give
me one simple tutorial link if you can.
Xironix
|
|
|
|
|
Read this?
http://www.codeproject.com/csharp/DzCollectionEditor.asp
I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.
|
|
|
|
|
Thanx.Yes I read this. But I can't implement it ? I can customize the CollectionEditor for my HolidayObject but the auto generation code did not created ! Serializing could not work !
|
|
|
|
|
heavenamour wrote:
I Wrote a calendar class that have a collection of holidays as an ArrayList. This collection is a property of my custom control that I want Add some objects of Holiday class to it at design time.
You have to do three things:
1. Use a strongly typed Collection, derived from CollectionBase instead of an ArrayList or Array. This allows the CollectionEditor to work properly.
2. Create a custom TypeConverter for Holiday, which is capable of converting a Holiday instance to an InstanceDescriptor . This allows the code generator to generate code to instantiate Holiday objects.
3. Decorate the collection property of your custom control with the DesignerSerializationVisibility attribute. This tells the code generator to serialize the contents of your collection, rather than the collection itself.
To illustrate these points:
using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
namespace Holidays
{
public class YourControl
{
private readonly HolidayCollection holidays = new HolidayCollection();
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public HolidayCollection Holidays
{
get { return holidays; }
}
}
public class HolidayCollection : CollectionBase
{
public int Add(Holiday item)
{ return List.Add(item); }
public Holiday this[int index]
{
get { return (Holiday)List[index]; }
set { List[index] = value; }
}
}
[TypeConverter(typeof(HolidayConverter))]
public class Holiday
{
public Holiday()
{
this.month = -1;
this.day = -1;
this.reason = null;
}
public Holiday(int month, int day, string reason)
{
this.month = month;
this.day = day;
this.reason = reason;
}
private int month;
private int day;
private string reason;
public int Month
{
get { return month; }
set { month = value; }
}
public int Day
{
get { return day; }
set { day = value; }
}
public string Reason
{
get { return reason; }
set { reason = value; }
}
}
internal class HolidayConverter : ExpandableObjectConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
return true;
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
{
Holiday holiday = value as Holiday;
if (destinationType == typeof(InstanceDescriptor) && holiday != null)
{
Type[] argumentTypes = new Type[] { typeof(int), typeof(int), typeof(string) };
ConstructorInfo constructor = typeof(Holiday).GetConstructor(argumentTypes);
object[] arguments = new object[] { holiday.Month, holiday.Day, holiday.Reason };
if (constructor != null)
return new InstanceDescriptor(constructor, arguments, false);
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}
HTH, Mark
Edit: I forgot one more thing. The CollectionEditor doesn't like non-default constructors, in fact, it can't instantiate objects without default constructors. So...
4. Add a default constructor to Holiday. The CollectionEditor has no way of specifiying constructor arguments.
|
|
|
|
|
Hi every body
I Wrote a calendar class that have a collection of holidays as an ArrayList. This
collection is a property of my custom control that I want Add some objects of
Holiday class to it at design time.I want to customize the .NET collection editor
to add my Holiday class instances instead of object type.Please help me.
My holiday class is very simple as follow :
public class Holiday
{
private int month;
private int day;
private string reason;
public Holiday(int month,int day,int reason)
{...}
//Properties
public int Month
{...}
public int Day
{...}
public string Reason
{...}
}
I read some articles is code project but they were very complicated.Please give
me one simple tutorial link if you can.
Xironix
|
|
|
|
|
Is this possible? Any code snippets are appreciated.
Brian
|
|
|
|
|
You can use the "Adobe Acrobat Browser Control Type Library" (PDF viewer) component.
<italic>Work hard, Work effectively.
|
|
|
|