|
Thanks Mervick. It works.
|
|
|
|
|
I have the following two chunks of code:
1)
NetworkStream networkStream = new NetworkStream(member.socket);
System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(networkStream);
...
2)
NetworkStream networkStream = new NetworkStream(s);
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(networkStream);
...
What would be the order for closing the streams and flushing? And do I need to do both on both the client and server side?
IE:
1)
streamWriter.Flush();
streamWriter.Close();
networkStream.Flush();
networkStream.Close();
2)
bw.Flush();
bw.Close();
networkStream.Flush();
networkStream.Close();
Thanks
|
|
|
|
|
You don't need to close the NetworkStream after closing the StreamWriter , the StreamWriter does it for you. MSDN says "Closes the current StreamWriter and the underlying stream". And closing the StreamWriter flushes it, so you don't need to Flush<code> before <code>Close
In short, all you need is
streamWriter.Close();
And you must close it both on the client and the server, each end creates some resources that must be released by calling Close .
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks.
|
|
|
|
|
I've 2 forms i want set a text inside the second form by the first one.
If i try i get a compiler error about permissing, the object (textbox is private).
What i heve to do?
|
|
|
|
|
hi,
can you change class where is your textbox private ? If so you can change textbox's modifier to public (not recommended) or internal (better) or you can write property for setting/getting value of textbox (recommended).
public means that everybody can directly change textbox's value - that's not good idea. internal means that everybody (classes) in same assembly can change textbox's value - that can be useful in some scenarios. By writing (public) property, you gain control over how and when can value change... e.g. you can have test for valid format of string or something and change actual value only if it's format is ok...
hope it helps
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
i've tried to set on modifier the value public but i get not permissing yet. why?
[quote]
you can write property for setting/getting value of textboxt
[/quote]
can you show me how?
|
|
|
|
|
Anonymous wrote:
you can write property for setting/getting value of textboxt
Anonymous wrote:
can you show me how?
public string TextBoxText<br />
{<br />
set(this.textBox1.Text = value;)<br />
get{return this.textBox.Text;}<br />
}
|
|
|
|
|
KEF
|
|
|
|
|
|
Is that a new code in c 2.0 ?
|
|
|
|
|
Is there a good way to debug Client/Server code, or rather, code in general? I have not familiarized myself with the Debugging options and therefore have noticed some odd behaviors IE: in debug mode, the program acts a certain way, which is wholly different from the way it acts during regular execution. Any good articles regarding .NET debugging that could aid me? Thanks.
|
|
|
|
|
In Visual Studio, you can go into the properties of your solution that contains both client and server projects, and set the start-up project to include both client and server projects. That way, when you start debugging, both client and server will be launched under the debugger.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: The Secular Left, the Religious Right, and Prejudice
Judah Himango
|
|
|
|
|
You are running into the classic problem with these client-server systems. The Client and the Server are operating in different application domains that occationally overlap and communicate with each other. Trying to debug these types of systems requires a level of understand that goes beyond what is normally done in "regular execution". Objects are not automatically available to either domain. Paths as well as context sensitive information are not the same in either domain. So on and so forth.
It is almost always easier to debug the Client application domain. The development tools are often available as well as the process so you can just attach the debugger and go. The Server application domain is often unavailable especially when on another machine that might not even be on the same network. It is also often a very bad idea to stop the server application domain in mid processing since whatever resource is still waiting for it to complete, like IIS. Defer processing or delay too many of these and your server can start acting weird.
One trick I always like to do especially if IIS is available is to report right to the HttpContext which can be inspected by "Trace.axd". Another trick I've learned to use is to have extensive log files that are coded into the server portion.
|
|
|
|
|
|
Well I'm assuming that if you have the means of installing the software on the server you also have the means of reading a log file too. The trick is of course is that is that there are multiple processes loging events so you have to do some heavy filtering to get any meaning out of it.
|
|
|
|
|
GRRRR. WORK DAMMIT.
Right so im using this to get files from my rescources:
<br />
ResourceManager rm = new ResourceManager("MyApp", this.GetType().Assembly);<br />
globalvars.HouseImage = (Image)rm.GetObject("house");<br />
Now this works fine for my pictures and whatnot, but im also using DirectX to play my sounds (Damn right i got that working - no SDK)
so its just
<br />
music = new Audio(@"filename");<br />
music.Play();<br />
but how can i play the file in my resources, i cant use:
<br />
globalvars.music = (Audio)rm.GetObject("song");<br />
<br />
<br />
globalvars.music.Play();<br />
(well the code is accepted but when the app starts i just get the error message)
So HOW CAN I PLAY THE FILE (from my resources and not from an external folder)
and GRRRRRR once again
|
|
|
|
|
The problem is that you need to take your raw resource (an .mp3 file or similar) and generate a DirectX.AudioVideoPlayback.Audio object from it. I don't remember offhand, does Play() allow passing in a stream instead of a file name? From there, you could get your resource object as a byte[], put it in a stream, then play the song from there.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: The Secular Left, the Religious Right, and Prejudice
Judah Himango
|
|
|
|
|
Hi,
I get the following error in an application.
System.Runtime.InteropServices.COMException (0x80040154): ?
I have set up a test machine where I can reproduce the error and it seems to be at a point where I am using SQLDMO to connect to a database. The wierd thing is that it works fine on my machine but not on a workstation. the only difference between the machines as far as database is that I have SQL Server 7.0 on my machine and the test machine does not.
How can I find out what is needed to resolve this issue as far as files etc?
Thanks
|
|
|
|
|
0x80040154 is an HRESULT error that translates to "Class not registered."
Do you have MDAC[^] installed on the test machine?
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
MDAC installed fine when I installed the framework for .NET.
|
|
|
|
|
Then look for another object that is using COM. The HRESULT is very clear: the object you are looking for is not registered and therefore can not be created let alone call any function upon.
|
|
|
|
|
Hi all
i have a tab page form. One tab has a file dialog that searches for a file on a form, and the other tab has a treeview that is populated with icons. When the form closes and i try to relaunch the form the following code:
myImageList.Images.Add(new Icon(imageFolder + "button.ico"));
goes looking for the icons at the last location that the file dialog returned,.... Why?
confused
|
|
|
|
|
Is the RestoreDirectory property set to true?
From OpenFileDialog help:
Gets or sets a value indicating whether the dialog box restores the current directory before closing.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Your code should never assume that the current directory will never change. That's what happening after your file dialog closes. It's changed the current directory.
Let me guess, the value of imageFolder is just a directory name and not a full path?
You should be building a complete full path to any file that your application attempts to get. You could easily accomplish your posted task by creating a small method that returns the full path to the imageFolder directory:
public string GetImageFolderPath()
{
return Path.Combine(Application.StartupPath, imageFolder);
}
Even better, have your function build the complete path to the image file:
public string GetPathToImageFile(string filename)
{
return Path.Combine( Path.Combine(Application.StartupPath, imagefolder), filename);
}
Then all you have to do in your posted code is:
myImageList.Images.Add( new Icon( GetPathToImageFile("button.ico") ) );
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|