Serializing Serveral Objects Through NetworkStream?
Jan 4, 2010
I apologise if this thread has been posted in the wrong section I was not certain whether it was the serialization or the networking that was causing this problem, but I feel that it is likely that it is the serialization.I am currently building two applications a client and a server, where several objects have to be sent between the applications, a couple objects each way.The applications are called "ACME Server" and "ACME Client" (yay for originality).
While I can get the first object to be transferred from the client to the server, but I can't get the second object to be transferred successfully from the server to the client, the error is occurring in the client program, I have taken a printscreen of the error that I am receiving, which I have uploaded to [URL]..All objects that are being sent are serializable (well there is an Interface called Action which I am unable to make serializable I believe due to it being an Interface).
[Code]....
View 1 Replies
ADVERTISEMENT
Jan 4, 2010
I am currently building two applications a client and a server, where several objects have to be sent between the applications, a couple objects each way.The applications are called "ACME Server" and "ACME Client" (yay for originality).While I can get the first object to be transferred from the client to the server, but I can't get the second object to be transferred successfully from the server to the client, the error is occurring in the client program,I have taken a printscreen of the error that I am receiving, I have uploaded to [URL]..
All objects that are being sent are serializable (well there is an Interface called Action which I am unable to make serializable I believe due to it being an Interface).
[Code]...
View 2 Replies
Feb 27, 2011
I am having problems with serializing and de serializing my objects.The following is my code for serializing buttons and labels which I have in my form.
Dim nodes As New List(Of nodeclass)
Dim objStreamWriter As New StreamWriter(filelocation)
For Each btn As Button In myNodeBtns
Dim u As New nodeclass
[code].....
I get an error: There is an error in XML document (20, 3).Now I have found out that this is because I have 2 root elements and 2 xml declerations. When I save the xml for the button and te xml for the label in 2 different files, I have no problem. However I have no idea how to go about saving the xml for both of them in the same file and deserializing it back.
View 4 Replies
Apr 5, 2009
I'm struggling with this Serializing of Data. and I've checked out the MSDN, and saw the Serializing an Array will make the out put like this:
[Code]...
View 13 Replies
Nov 11, 2009
I am in the process of writing a base class for gadgets that will be displayed on a form.I want the gadget to be fully self contained and reusable.At this point it does everything that I need it to do EXCEPT, i'm having trouble figuring out a creative way to serialize my objects using only one object.I have a feeling the answer lies somewhere within the context of using shared functions but I'm having trouble wrapping my mind around it.
View 1 Replies
Dec 21, 2009
I am trying to create a load and save function for my customizable Menu/Tool/StatusStrip controls (see signature). Those three controls use a single AppearanceControl class, which is mainly just a large list of properties (Colors) which control the colors of the Menu/Tool/StatusStrip.
I want to be able to save and load the values of these properties so the user can store them and load others with ease. Serialization seemed the obvious answer, although I never used it before.
Now, there is a slight problem that I cannot serialize Colors, so I simply gave each Color property the XmlIgnore attribute, and created an Integer property that gets and sets the Color property (using Color.ToArgb and Color.FromArgb). This way I can serialize the color properties succesfully.
Then, there is another problem. The properties are not all in the AppearanceControl class. Instead, the AppearanceControl class has a large number of subclasses, which in turn contain the color properties.
As a small example, I may have this:
vb.net
Public Class AppearanceControl
Private _toolStripColorProperties As ToolStripColorProperties
Private _menuStripColorProperties As MenuStripColorProperties
[Code]....
View 6 Replies
Oct 30, 2009
I need to download serveral years worth of files from a web site, the web site posts files daily in "Date".csv. How do I write the code in vb.net to get the string value for the dates? I know that you can do something like : Dim start date = #11/01/2009# and Dim end date= Now.
How do I get these values so I can incorportate them in a string? And then loop through each value.
It will need to start with the first date an download that file, then loop through all the dates downloading each file until it has reached the end date. I already have the code written to extract the info i need from the document and import into a sql server, my only issue is the date range string issue
View 9 Replies
Jan 8, 2010
I know it's subjective but this was the result I came up with based on the answer to me previous question and it seems a bit "slapped together", as I have changed it quite a bit:
[Code]...
Basically is there a better way to write this (even just part of the code) or a more efficient way to do it?
Basically the code is there to read all the bytes from a networkstream 1024 bytes at a time. And each time it reads the bytes it puts into one array which is returned.The thing i think might be better is only Redim byteTempbuffer if intRead is less than 1024 (the redim is to prevent empty bytes from being added to the end of the array when there are less the 1024 bytes left to read from the networkstream) (basically is it more efficent to Redim every time or to go through and if statement and redim only if needed)
View 1 Replies
Jul 3, 2009
How do I know where the other end of the NetworkStream from the 'server' computer? I have been looking at the following code that comes from a post out here, and am wondering where I can tell where I am going to send back to(URL/port)?
Private Sub DoListen()
Dim incomingClient As System.Net.Sockets.TcpClient
Do
[code]....
View 5 Replies
Mar 18, 2010
How would i load and image from network stream as bmp?For example the client sends a image thats jpg. but the server displays the image on a picture box property as bmp.
View 3 Replies
Sep 5, 2010
This question is about trying to find a way of telling what is being sent of the NetworkStream as in whether it is Text or Binary. For example I could have a Server program on my Girlfriends computer and the Client Program on mine, two functions on each:
Server: Textbox for catching any text sent (like a chat for example) and a function for receiving files (like an EXE or others)
Client: Textbox for sending text to the client (again like chat) and a function for sending files (again like EXE or others)
How do you code the server to tell it how to determine which is which (Binary or Text) and further more what if the file being sent isn't an EXE, what if its an image or a text file or other type? I already know how to send a file through to the server and put it back together on the other side but thats only sending an EXE file. I'd want to enable an update functionality in the server so it can receive a message from the client saying its sending through an update which once the server gets the message it will know what to do on the other end (i.e. stopping itself whilst the update.exe is running and copying over the new file).
View 8 Replies
Jun 22, 2010
I am attempting to write a vb.net 2008 application that will allow me to send files from a server to a client based on a request. I am going to post the same console application code below. When i run the server and the client on the local machine, i can get my file update and it works just fine. When i go to a different machine on my network and attempt to connect to the server and download the file, i get the correct file size but the file, when i attempt to run it, says "not a valid win32 application". Now with a little testing, this can be any executable that i send over the network through my update software.
------
SERVER
------
Imports System.Net.Sockets
Imports System.IO
[code]....
View 1 Replies
Jun 8, 2012
I am new to vb.net programming. I am trying to connect to a device using TCP/IP.I am trying to send a command "Z<CR>" where Z is a character and <CR> is a ASCII value of 13. How can i do this in one statement?
I have written following code, but my program stops responding at .read statement:
[Code]...
View 2 Replies
Jun 28, 2010
I have an XDocument ready to be sent out via Network stream, what do I need to get it working? I am connected via networkstream and can send regular text, but I don't know how to send an XML Document, I use the networkStream.write() function to send in text.
View 2 Replies
Jul 31, 2009
I am sending some data over a networkstream. The datasize is 97 The buffersize is 1. Data is a list of bytes. When the bytecount reaches 94 the do while loop exist itself.
[Code]...
View 2 Replies
Jul 22, 2012
I am doing client/server socket based project and currently I am having some troubles with the recieved result.What I mean ... this is part of the client which is receiving
tcpClient.Connect(address, Port)
Dim
bytes(tcpClient.ReceiveBufferSize) As
Byte
[code]....
Where file is just a simple file name send from the server. What I recieve is for example: test.txt%00%00%00%00%00%00%00%00 etc. The server and the client are using the same encoding ASCII.
View 1 Replies
Jun 1, 2011
I have some troubles reading an image from a networkstream.Every time the when program runs this procedure its shuts down without a warning.[code]...
View 11 Replies
Mar 19, 2012
My code looks very similar to this post Read bytes from NetworkStream (Hangs), which I copied below. ( I realize this is c# - I need a vb solution)
[Code]...
My issue lies in this:
I have a form that takes user input on which tif file(s) to find (which ends up being the getBytes(message) ). When one does this, it always returns one result - the first tif file that fits the criteria, However, I know in certain instances I should recieve more than one match.
Then I send the results to a picturebox and should be able to scroll through results (which this part works fine)I've tried a few ways to get multiple results, but maybe I'm missing the obvious? My best guess is using the asyncronous beginread/write.I've attempted using a for loop but I end up getting a bunch of the same tif files as a result..
View 1 Replies
Dec 11, 2011
I'm using the following code to get newsgroups from a server[code]...
When I execute the code, the routine only receives one block of the data. However, if I go into debug mode with a breakpoint at the loop instruction, I receive all of the blocks of data.Am I missing something in the code, like a wait or something, that would allow the program to receive all data like happens with the debug?
View 1 Replies
Dec 8, 2011
I'm using the following code to get newsgroups from a server:
sendBytes = Encoding.ASCII.GetBytes("LIST active microsoft.public*" & ControlChars.CrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)
[code].....
View 2 Replies
Apr 18, 2011
I have a device that is continuously sending text over a TCP port and I want to write a VB.net application that will read and evaluate this data. Each line of text that arrives over the port can be of varying length and each value in the line is separated by a comma. I need to separate out these values in order to take various actions based on their contents.
The following code appears to read the NetworkStream fine but when I try to read the data into an array and output one field into a text file the code is only catching a few lines of the high number coming through the port.[code]....
View 3 Replies
May 11, 2011
I was trying to develop a video chat p2p system by sending bitmap of the picturebox where the webcam performs. I want to send and make the client just prompted without having the client to save the file by opening savefiledialog of the bitmap i was sending.
The sending part was like first I copy the frame of the picturebox which showing the video cam, and saved it into memorystream as .bmp file like this:
ms = New MemoryStream()
Dim a As Image
a = Server1.copyFrame(Me.PictureBox1, New RectangleF(0, 0, _
[Code]......
View 14 Replies
Jul 15, 2009
I'm trying to make a simple chat client. But it seems that the "Dim ClientData As String = Encoding.ASCII.GetString(RevievedBytes)" is returning a string without the trailing quotation. During a step-into, ClientData was "something instead of "something". If I manually put the other quotation on the end during a step-into, it would work. Why is this happening? Full project available at [URL]
[Code]....
View 9 Replies
Mar 30, 2011
I have just finished my application and am stuck as to how I'm going to store my data. As it stands I have multiple objects that I created but each of them take multiple ArrayLists as properties. I'm aware that this will give problems if I try to serialize my data?
View 4 Replies
Oct 9, 2009
I'm trying out MVVM in VB.Net for a while now and started out with some of my entities using List(of T)s, which I xml serialized to disk. Now, I updated the classes used by the Lists to implement INotifyPropertyChanged so I also changed the List(of T)s to ObservableCollection(of T)s.After which, the XML serializer stopped working :'( A colleague told me that ObservableCollections, unlike generic Lists, are not serializable.If so then how can I make them Serializable?
View 2 Replies
Feb 10, 2010
I have a class that I want to be serializable but contains a public instance of delegate that, apparently can't be serialized: [Code] Is there a way to make it serializable however?
View 4 Replies
Jan 8, 2010
It seems the most obvious thing, but I just can't work out how to get the length of bytes sent over a network using a TCPClient and TCPListener? This is my code so far:
'Must listen on correct port- must be same as port client wants to connect on.
Const portNumber As Integer = 9999
Dim tcpListener As New TcpListener(IPAddress.Parse("192.168.2.7"), portNumber)
[Code]...
I need to get the length of the networkstream to set the size of the array of bytes I'm going to read the data into. But the networkStream.length is unsupported and does not work and throws an Notsupportedexception.
The only other way I can think of is to send the size of the data before sending the data, but this seems the long way round.
View 1 Replies
Dec 2, 2010
I'm using the code at the bottom to connect to a Usenet newsserver. This code works fine, but it freezes the UI, so I need to do it asynchronously.
[Code]...
View 6 Replies
Apr 29, 2010
I'm not positive I'm going about this the right way. I've got a suite of applications that have varying types of output (custom defined types).For example, I might have a type called Widget:
Class Widget
Public name as String
End Class
Throughout the course of operation, when a user experiences a certain condition, the application will take that output instance of widget that user received, serialize it, and log it to the database noting the name of the type.
Now, I have other applications that do something similar, but instead of dealing with Widget, it could be some totally random other type with different attributes, but again I serialize the instance, log it to the db, and note the name of the type. I have maybe a half dozen different types and don't anticipate too many additional ones in the future.
After all this is said and done, I have an admin interface that looks through these logs, and has the ability for the user to view the contents of this data thats been logged. The Admin app has a reference to all the types involved, and with some basic switch case logic hinged upon the name of the type, will cast it into their original types, and pass it on to some handlers that have basic display logic to spit the data back out in a readable format (one display handler for each type)NOW... all this is well and good...Until one day, my model changed. The Widget class now has deprecated the name attribute and added on a bunch of other attributes. I will of course get type mismatches in the admin side when I try to reconstitute this data.
I was wondering if there was some way, at runtime, i could perhaps reflect through my code and get a snapshot of the type definition at that precise moment, serialize it, and store it along with the data so that I could somehow use this to reconstitute it in the future?
View 1 Replies
Dec 25, 2011
Possible Duplicate: Fastest serializer and deserializer with lowest memory footprint in C#?
I'm using BinaryFormatter class to serialize an structure or a class. (after serialization, I'm going to encrypt the serialized file before saving. (And of course decrypt it before deserialization))But I heard that some other serialization classes are present in .Net Framework. Like XmlSerializer, JavaScriptSerializer, DataContractSerializer and protobuf-net.I want to know, which one is best for me?Less RAM space needed for serialize/deserialize is the most important thing for me. Also speed is important.
View 2 Replies