Get Away With Packing Data Into Serialized Objects?
Feb 24, 2011
I have a thought about using a Serializable Collection containing both data objects and also sub-collections as a low-grade database, meaning it's going to store data objects that are expected to be added to regularly and deleted from occasionally.
I have used XML serialization to persist objects in my application but I am now interested in using null- able Data types for properties. Will I still be able to serialize?
This is my first post on here--I've been teaching myself VB via forums like this and MSDN for about 2 years now. I'm programming a computerized economics experiment, and I'm using a communications package that a guy I worked with developed. He and I have been going back and forth trying to figure out what the heck is going on.
The upshot of the communications package is that there's a serializeable MQMessage class that we send back and forth, essentially just a package of an integer (Type), string (Text), and Object (Data). Most of the time, this goes according to plan.
The problem is this: If the client receives two or more messages back-to-back, the client stops raising the MessageArrived event. (and presumably, the same would hold true for the server--I should test this, but jeez-oh-man, I've been running test after test for the last week).It's still connected, as on disconnect it throws the "Socket forcibly closed" exception. When it receives multiple messages sequentially, it's still receiving the data, it just never knows when the first message ends, and the buffer just keeps filling and filling. The problem seems to be that it can never successfully Deserialize the MQMessage object, and so it returns Nothing on the getCompletedMessage function and just keeps adding to the buffer (ABuffer.Length goes 1024, 2048, etc.).
How can I send and recieve serialized objects over a TCP connection with size and data type values in the header (within array(0) and array(1) values)?I know how to serialize and send the object using BinaryFormatter.Serialize.I dont know how to take the recieved data and put it into an array of bytes().Also - on the receiving end I dont know the size of the object sent therefore I dont know when to stop reading the data stream so I cant use: Dim Obj As ClassName = DirectCast(BinaryFormatter.Deserialize(Stream), ClassName).
i would like to encrypt my data files, which are serialized object files. is there a simple way to do this that will work trouble free on both windows xp and vista?
my environment: windows xp pro (sp3), visual studio 2008 pro, (sp1, sdk 1.1)
I tried using MoleBox pro, it woulnd't even start, how would I pack some files with the .exe so that when i type something like shell "drum.exe" it will run drum .exe? But drum.exe wont be out in the open.
I am planning on sending some of my friends and colleagues a copy of a program that I made. For this program I was going to include a .zip file of some extras for them to look at. Is there a way in VB.NET to create a .zip folder, copy things from the program's resources into the .zip folder, and then later on be able to unpack them? PS - The purpose of this is to copy items from the resources into the .zip folder so that I can send everything in one program.
I am trying to round-up in VBscript but am hitting blanks... My script so far is... Value = Quantity / Packing Value = Int(value + 0.8) Quantity and Packing are variables and always needs to round up.
I just wanted to ask, if it's possible unpack or pack different archives like .iwd with winrardll, as winrar opens them without problems, and makes them as easy as opening them If it's possible, would process be the same, just with .iwd extension? If it isn't, is there any other way to do it?
In .NET (at least <=2) there's a problem serializing objects that raise events when those events are handled by a non-serializable object (like a Windows Form).Because of the way VB.NET implements events, when you serialize an object, its events get serialized too (because events are actually implemented using hidden multicast delegate fields). A side effect of this is that any object which handles events raised by the object being serialized will be considered part of the object graph and will be serialized too.
Some workarounds could be found, implementing custom serialization or using delegates instead of events:[URL]..
I'm building a simple game which involves many pictureboxes with which the player may collide. For instance, I'd have a hundred bricks spread throughout the level. In an old version of pacman I built in VB6 (and upgraded to .net), I implemented this like so: [Code]
As I understood, the brick(I) array exists thanks to the naming of the bricks, which ranges from _brick_0 to _brick_217 (as nowhere in the project a brick array is declared implicitly, at least not that I could find). I'd like to do the same in my current project, but even when I duplicate an existing brick it automatically renames it to "PictureBox123" instead of _ExistingName_NextID.
I saw a method of declaring a picturebox array and adding the bricks one by one, but since I have so many pictures this would best be avoided (especially due to the fact that not all pictures are bricks, so I cant just loop through every picture in the form). In short, my question is: How do I duplicate pictureboxes so that they'd be serialized in a way vb.net would interpret as a picturebox array? As you can see, i'm a really newbie to vb.net and wf in general, just started studying wf a couple days ago for my B.Sc and even that was accomplished with c#.
I have created a class from an xml schema (that I do not own and cannot change) using xsd.exe. Using this class, I am deserializing to bring the data in to an object collection to consume. There are times when I want to take objects in memory and pass them to the class created by xsd.exe using a constructor I built to generate a serialiable object collection.
I cannot figure out how to format some objects correctly Example: In the xml file, there are certain simple types that are floats that come in with 6 digits of precision. When I write them out, they have 7 digits of precision. Anorther example is integers with leading zeros in the xml file. They come in as 4 digits regardless of leading zeros, but I can't find a suitable way using serialization to output them (other than to change the property to a string datatype.[code]...
I am generating this XML using the serializer in VB.net as shown below
Dim string_writer As New StringWriter() Dim serializer As New XmlSerializer(GetType(MyClass)) serializer.Serialize(string_writer, addr) txttest.Text = string_writer.ToString()
though it is returning XML, I see xmlns="http://tempuri.org/ in all the elements, is there anyway I hide this one.
How can I send and recieve serialized objects over a TCP connection with size and data type values in the header (within array(0) and array(1) values)?
I know how to serialize and send the object using
BinaryFormatter.Serialize
But on the receiving end I dont know the size of the obejct sent therefore I dont know when to stop reading the data stream. I also dont know how to take the recieved data and put it into an array of bytes().
Let's say I have the following class structure (simplified from my real-world problem):
Public Class PC_People_Container Private _people_list As New List(Of PL_Person) Public Sub New()[code].....
If I were to serialize this, I'd get the default assigned node names in my XML. That means my root is named PC_People_Container and each person in the list is marked up as PL_Person. I know I can change the root node using <XmlRoot(ElementName :="PeopleContainer")>. The trouble is doing that for the subclasses. I can't use the <XmlRoot> tag on PL_Person class because there can't be two root elements, and IntelliSense throws a fit when I try to use the <XmlElement> tag on a class like I would on a property. Is it even possible to control what those subclasses are named when they're serialized as child nodes?
I need to add some code to the EndInit method of a PictureBox control but unfortunately its private and, from what I can gather, I can't shadow it and call base - at least not in VB.Net.What I can do is add a dummy property to my picture box class. The type of the dummy property is simply a class that just implements ISupportInitialize. However, that doesn't work, I need the dummy class to inherit from Control.Is that the minimum requirement?
I'm trying to send a XML serialized class over a network stream
the send is working
Dim IP As Net.IPAddress = System.Net.IPAddress.Parse(IPAddress) Dim IPE As New Net.IPEndPoint(IP, 10003) Dim TCPClient As New Net.Sockets.TcpClient
[Code]....
I always get an error {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."} The XMLFile has the xml document in it most of the time and I can go on and everything works but 1 out of every 5 times it doesn't work at all and the XMLFile contains nothing ..
<Serializable()> Public Class GOODownloadFile Private aID As String Private aDownloadLink As String
[code]....
Now when I create an object like this
Dim f As New GOODownloadFile("http:\download.com1.exe", "c:Down", "c:Down") downloader.AddDownloadFile(f) downloader.WriteInfoFile("C:1.txt")
All the values given are correctly saved in the file 1.txt But when I change the download file info afterwatds, like this:
Dim f As New GOODownloadFile("http:\download.com1.exe", "c:Down", "c:Down") downloader.AddDownloadFile(f) downloader.WriteInfoFile("C:1.txt")
[code]....
the new value (123456) is not saved. Hence, only the values provided BEFORE the AddDownload are saved, the rest aren't. I've check my code 100times, and I'm sure everything is fine. I think it may be because of the send-by-value. When I change the values afterwards, the orginal object isn't used.
I'm building a simple game which involves many pictureboxes with which the player may collide. For instance, I'd have a hundred bricks spread throughout the level. In an old version of pacman I built in VB6 (and upgraded to .net), I implemented this like so:
Basically, I need to transmit data across a network from point A to point B using a Binary Serialization System. I'm doing this to make sure that the system can't have outside listeners read the data being sent easily and to keep results secure and confidential.What is an easy way that I can encrypt, say, a generic object? Would it be easiest to serialize it to file, read the bytes in, encrypt the bytes, then store the bytes in a serialized structure and send that across the stream and reverse the process?
Private Function EncryptClass(ByVal obj As Object) As Byte() Dim key() As Byte = {52, 15, 85, 150, 45, 12, 78, 120,
I have a serializable Message class that has a Data As Object property that I'm using as a generic holder for information to be sent via a system that uses a combination of push technology and/or IPC to communicate with any other programs that are interested in the information. This allows the communication piece to be agnostic of the information it transmits.
I was serializing this Data As Object as a Byte[], since I was worried about how an Object being serialized and transmitted across the network would behave on the other side. However, when deserializing I get errors about being unable to find the assembly for the types stored within my Data As Object property, because I'm deserializing in the assembly that contains the Message class... not the assembly that contains the type that Data As Object originally was.I was wondering if I'd lose the type information and be unable to cast it back to the type I want at the other end. Perhaps it's not possible to pass a type as an Object via another assembly without it knowing about my type?
I attempt to serialize an object, and it throws an exception as shown below. I assume it attempts to serialize also the UserControl that subsribes to an event of the class I try to serialize. This is not desired. So how do I avoid serializing events?
SerializationException occured:Type 'System.Windows.Forms.UserControl' in Assembly'System.Windows.Forms, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089' is not marked as serializable.
trying to create a WPF application that will allow users to print a barcode label written in ZPL that is saved to a text file on the C: drive. I am able to print the barcode with the WPF Application except it prints the same serial # without incrementing to the next one. I would like have the application:Open the test.txt file and read the last serial # that was printed. Print the next serial #. Write the last serial # it printed to the file for the next it is printed so that if I printed 1,2,3 this time, the next time it would print 4,5,6. Below is my code for the test.txt file and my VB.net code.
test.txt ^XA ^LH20,10^AE^FDBUILD LABEL^FS
[code]....
The printing process doesn't look pretty, but I was unable to get it to print with PrintDocument.Print() and I could by using a Process. I am guessing the issue is with intSN declaration not appending the serial # back to the test.txt file, instead, it adds the barcode back to the file.
I am currently working my way through a MSDN Walkthrough titled Connecting to Data in Objects, the link for this is
[URL]
I have worked up to the section Adding Code to Load Data into the Customer and Order Objects section with no problems, but the Public Class Form 1 code is throwing an error hilighted in italics as per below,
Private Sub LoadOrders(ByRef currentCustomer As Customer) Dim orderData As NorthwindDataSet.OrdersDataTable = _ OrdersTableAdapter1.GetDataByCustomerID(currentCustomer.CustomerID)
This is the Description returned from the error list,
Error 1 Description - Value of type 'ObjectBindingWalkthrough.NorthwindDataSet.OrdersRow' cannot be converted to 'ObjectBindingWalkthrough.NorthwindDataSet.OrdersDataTable'.
[code]....
In the walkthrough I also came across a problem under the heading Modifying the Query on the OrdersTableAdapter to Return Only Orders for the Desired Customer This SQL throws an error,
But the following edit to the Where clause gets around the error, the @ symbol is removed,WHERE CustomerID = CustomerIDcould this be causing the problems I am having described above, or is this just an error.
This is getting on my nerves. All the examples I keep finding deal with Consoles, all I'm trying to do is put data into an array of objects and output them into a Text box, but I don't know the syntax to do that.Here's my class
Public Class Student Private SID As Integer Private firstName As String
I am in the processing of migrating from web services to WCF, and rather than trying to make old code work in WCF, I am just going to rebuild the services. As a part of this process, I have not figured out the best design to provide easy to consume services and also support future changes.