|
Hi
i am using following code to connect to ftp server on my own pc.
socket.Connect(endpoint);
then i m calling following code to read response.
noofbytes = clientSocket.Receive( buffer, buffer.Length, 0 );
when i m calling this sometimes, program hangs, it does not hang when i m debugging. so i have added System.Threading.Thread.Sleep(20) to sleep program, now its working, i want to know the reason program is hanging, and also i used 20 milliseconds after experiment. it may change on different machines.
Shajeel
|
|
|
|
|
try reading in smaller chunks
60% of statistics are made up on the spot
|
|
|
|
|
Hi everyone,
I am doing a small project in asp.net which uses MySQL as back end.there is a field to store Hours in my table.I gave the datatype of double to that field.
Now I select the contents of the table and the resultant dataset will be bound to the datagrid as usual.
Here my double Hours field is truncating the trailing zeros.If total hour is 5.30 its showing as 5.3, but for 5.15 it shows 5.15 as correctly.how to fix this.
this may be silly ...but I need help from some one......
Thanks
|
|
|
|
|
Actually no data is lost. It's just a matter on how the data is formated when being output. Have a look here[^] to get an overview of what is possible with formatting.
Generally speaking you can format your double the way you want. In your example it should be something like:
double d = 5.3
Console.WriteLine(d.ToString());
Console.WriteLine(d.ToString("#.00"));
Console.WriteLine(d.ToString("00.00"));
|
|
|
|
|
I wanted to reset the record number on beginning of odd page numbers (Not applying to the page number 1) to immediate previous even page beginning record number. Ex. if page 2(even page number) starts with record number 1, then I wanted to reset the record number to 1 in the next odd page number (i.e. 3). Similarly if page 4(next even page number) starts with record number 26, then I wanted to reset the record number to 26 in the next odd page number (i.e. 5). This should continue through out the report. Is it possible do this? Please comment on this.
Or anybody have any idea to display lengthy records (Which has several columns) runs up to 2 A4 papers in continuous order. Ex. Assume it show 25 records in the first page and remaining columns same 25 records in the next page. Then it should show the records from record number 26 at the next page. This should continue through out the report.
Thank you in advance.
Sam J
|
|
|
|
|
Hi..
Crystal does have global variables for pagenumber, or force reset of pagenumber, and you probaly have to to do this check and reset on the page header or footer group.
.NET Rules
|
|
|
|
|
I tried that. But the record number is a read only value. Isn't it? So how to set a value to it even though the check can be done at the page header?
Sam J
|
|
|
|
|
how would i initialize a static array?
|
|
|
|
|
Either in a static constructor or inline:
static int[] intArray[] = { 1, 2, 3 }; I hope this helps!
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
Hello everybody
I'm trying to scale down a image file, the thing is that I can't find anyway to do that without getting the image into a Grapgics object.
Using the graphics object to scale down is easy (using ScaleTransform()), the thing is that I want to convert back to Image in order to place the image in a picturebox.
can anyone help me with that???
Thanks in advance!
|
|
|
|
|
Instead of changing your instance you could create a new one:
Image oldImage;
Image newImage = new Bitmap(wantedWidth, wantedHeight);
using (Graphics g = Graphics.FromImage(newImage))
{
g.DrawImage(oldImage, 0, 0, wantedWidth, wantedHeight);
}
|
|
|
|
|
how can i change the machine name using C# code?
|
|
|
|
|
complete method is available at following link.
http://www.thescripts.com/forum/thread108650.html
Shajeel
|
|
|
|
|
Say, I have this string ℵ, the hebrew Alef Symbol. In the charmap program it maps to the Unicode code point U+2135 (hex). However when I do a GetBytes on a string with alef in it, I get back a 3 byte representation: E2 84 B5.
I'm just confused on how to map this back into 21 35???? How does the hex E2 84 B5 relate to 21 35. Why does charmap say alef is 2 bytes, when UTF8Encoding.GetBytes says it's 3 bytes?
/\ |_ E X E GG
|
|
|
|
|
What encoding do you use?
If you use UTF8, for instance, most characters are encoded as 8 bits, but the characters that really need 16 bits have to use an extra byte to form an entity that contains 16 bits of data and still is distinguishable from two regular characters.
If you examine the bit pattern of the bytes, it's easy to see how it works.
The binary code for 0x2135 is 0010000100110101. This is divided into three parts: 0010, 000100 and 110101.
By adding 1110 before the first part and 10 before the two other, you get the patterns 11100010, 10000100 and 10110101, which written in hexadecimal are 0xE2, 0x84 and 0xB5.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: By adding 1110 before the first part and 10 before the two other
Where did you get the idea to do that?
/\ |_ E X E GG
|
|
|
|
|
Hi,
I want to create label array. Like this lable1[0], lable1[1]...
Thanks...
|
|
|
|
|
dataminers wrote: I want to create label array. Like this lable1[0], lable1[1]...
I shall allow this.
Seriously, though, it's not different from making an array of other objects. Are you making an array of labels already on a form?
Label[] label1 = new Label[] { firstLabel, secondLabel, thirdLabel, ... };
Or to make an array of labelCount labels:
Label[] label1 = new Label[labelCount];
label1[0] = new Label();
label1[1] = new Label();
--
I've killed again, haven't I?
|
|
|
|
|
Good afternoon.
How to send the e-mail through Outlook that there was no window Outlook Security in C#?
HOW use MAPI in C#??? Please take the sourse in which e-mail letter sends.
Thanks!
|
|
|
|
|
Hello programmers,
I wrote a remoting server and a client. I use some basic Remoting techniques:
1) There is a class/interface (remote object) declaring the Functions, like "String SendCommand(String text) ". Lets call it RemoteObj (IRemoteObj ).
2) Then, I register a well-known Type:
RemotingConfiguration.RegisterWellKnownServiceType(<br />
typeof(RemoteObj), "RemoteServer",<br />
WellKnownObjectMode.Singleton);
Now there is my problem: When the client executes the method, then i need to handle it completely inside the RemoteObj since i dont have a reference to the registered Object instance. This is not what i want actually, because i have the whole ready application around the RemoteObj Object which is able to return the whole data needed. The Remote Server is just a part of my application, not the other way round.
Is there a possibility to reference the Singleton object instance? I even could imagine to handle the communication by delegates/events.
Can you help me?
Thanks in Advance!
|
|
|
|
|
Your question/problem is not very clearly stated....
however here is how I deploy remoting.
On the server side I have RemoteClass which inherits IRemoteEntity (I changed your name to avoid confusion)
On the remote side you should register IRemoteEntity NOT RemoteObj
On the client side you want to connect to the remote server asking for a type IRemoteEntity. All references on the client side work with the IRemoteEntity instead of the RemoteObj.
So now I have a reference via an instance variable in the client to my remote object which was defined
IRemoteEntity remoting;
Now I can do this:
string value = remoting.SendCommand( command );
All code is now executed on the remote server.
|
|
|
|
|
Ok thanks so far, but this is not exactly the problem, let me explain further.
You explained how to contact the Remoting Server from the Client, so lets continue from there.
The Server received the command String sent from the Client (from SendCommand Method. Now, everything happens in an instance of RemoteObj (which implements IRemoteEntity and MarshalByRefObject ).
But now, the RemoteObj needs information from the current instance of the Server Application which originally registered the Service (you remember my first post? ), which is the instance doing the actual work.
But i dont have any reference to the instance neither from the RemoteObj to the server application, nor the other way.
I hope, you can understand now.
Here is another very small example:
using System.Runtime.Remoting...
namespace MyService
{
public class SimServer
{
private int listeningPort = 17998;
private TcpChannel channel;
public int justATestVariable = 123;
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(MyService.ServerObj), "TheServer",
WellKnownObjectMode.Singleton);
}
public class ServerObj : MarshalByRefObject, IRemoteEntity
{
public String SendMessage(String message) {
}
}
}
Now, imagine the Server was started, therefore a single instance of MyService.ServerObj was created. Then, the method SendCommand was called from a client, and the Serving Object (ServerObj ) needs the current value of justATestVariable to be able to reply to the clients request.
Any advices?
Thank you!
|
|
|
|
|
Your class SimServer is usually called the Remoting Host. In all designs I've seen so far, the only purpose of the Host was setting up the Remiting environment and providing the process the Server (your class ServerObj) runs in. I've never tried to establish any communication between the Remoting Server object and its Host. Therefore, the following approach is just an idea and has not been tested.
If the Server and the Host exist within the same AppDomain of the Host's process, you may declare certain methods/properties of the Host static.
<br />
namespace MyService<br />
{<br />
public class SimServer<br />
{<br />
static public int justATestVariable = 123;<br />
}<br />
<br />
public class ServerObj : MarshalByRefObject, IRemoteEntity<br />
{<br />
int myCopy = SimServer.justATestVariable;<br />
}<br />
}<br />
Alternatively you can make the Host a singleton and access its only instance from your server object.
If the Server and the Host are placed in different AppDomains, things will become more complicated. You will have to set up a separate channel of communication between the two objects, e.g. using pipes. There are some articles here on CP about this topic.
|
|
|
|
|
Thanks Tim for your reply and your explainations
I really appreciate your help!
I understand your design approaches, but i want to clarify my approach here:
Looks like i run into that problem because the application was originally never designed to be a server, but we found out later, that it might be very handy to have it started on a server machine and be able to get the needed data by requesting it from a small client application. So the basic idea of the remoting server functionality was more just a plugin or addon feature to the main application, therefore, the main application became just a host and not the Remoting Server itself. It can run completely without the server, it has its own GUI, its even based on its GUI.
So this is the main reason why the - let me call it: "Remoting Server Plugin" needs most of its data from the host.
The idea to provide Static methods is maybe not cleanest design but it might be the easiest one. I have no idea how to make the Host a Singleton.
Well thanks again!
|
|
|
|
|
In C# it is really simple to create a Singleton. You don't have to use the double-checked locked accessor as it is used in C++ or Java.
public class Server
{
private static readonly Server _instance = new Server();
private Server()
{
}
public static Server Instance
{
get{ return Server._instance; }
}
}
Within your code you now must use Server.Instance instead of new Server() . Thus your "Server Host" and your "Remoting Plugin" will access the same object.
|
|
|
|