Using .Net XmlSerialize For Strings With Embedded <cr><lf> Loses <cr> When Deserializing?

Oct 13, 2009

The following (abysmal) code demonstrates how standard serialize/de-serialize in VB loses the CR when on de-serialize. This can be overcome by applying 'XmlAttribute(DataType:="string")' to Description. Why does it do this? I would like to fix this without applying a 'LF' -> 'CR''LF' in every affected class. This is fixing a bug in existing XML files generated without the XmlAttribute!

Imports System.Xml.Serialization
Imports System.Xml
Imports System.IO

[code]....

View 1 Replies


ADVERTISEMENT

VS 2005 : User Settings Metric/Imperial XMLserialize?

Apr 1, 2009

I am having a bit of an issue and would like some opinions. I have a settings class that I use in my program that gets passed around to various pieces of the program. When the program exits, the settings class is serialized out to an xml file. When the program starts the settings class is serialized back from the xml file.If the program doesn't find an existing xml file, the defaults in the class are used and a new xml file is created when the program exits.This all works well. Here is a trimmed down version of my settings class:

Public NotInheritable Class UserSettings
Private _Length As Double = 10 'feet
Private _Name As String = "Inert Material"

[code]....

The problem that I am having is that if the program units are metric, then the default values are always converted in the constructor and the xml serializer then stuffs the values that exist in the configuration (over writing the converted default value which is what I want) into the proper properties. The reason for this behavior is to make sure that that new properties that don't exist in the xml file have a proper default value when metric units are required.

It seems wasteful to convert all of the default values every time when working with metric units? Is there a better way to do this? My full class has currently about 15 default values that need to be converted to metric equivalents. Ideally I would only like to convert values that haven't come from the xml file.

View 2 Replies

VS 2005 User Settings Metric/Imperial XMLserialize?

Jun 1, 2011

When the program exits, the settings class is serialized out to an xml file. When the program starts the settings class is serialized back from the xml file.If the program doesn't find an existing xml file, the defaults in the class are used and a new xml file is created when the program exits.This all works well. Here is a trimmed down version of my settings class:

Public NotInheritable Class UserSettings
Private _Length As Double = 10 'feet
Private _Name As String = "Inert Material"

[code].....

View 2 Replies

Way To Concatenate List Of Strings Into A Comma-separated Strings, Where Strings Are Members Of An Object?

Oct 16, 2009

Say I have a List(Of Tag) with Tag being an object. One member of Tag, Tag.Description, is a string, and I want to make a comma-separated concatenation of the Description members.Is there an easier way to do this than to read the Description members into a List(Of String) and then use the Join function?

View 2 Replies

.net - Deserializing XML String?

Jul 18, 2011

I'm receiving the following xml string (i've removed the actual namespace name)

<?xml version="1.0" encoding="UTF-8"?>
- <changeNotificationDto xmlns="http://www.Company.com/item" changeEventTypeCode="RemoveDeliveryPoint" messageId="10" sentDateTime="1970-01-01T00:00:00.000Z">
- <entry action="Remove" type="DeliveryPoint">
- <removeEntityNotification>

[Code]...

View 1 Replies

C# - Deserializing Objects With New Members

Jan 23, 2011

According to a mspress book (MCTS for Exam 70-536 .NET 2.0): You might have version compatibility issues if you ever attempt to deserialize an object that has been serialized by an earlier version of your application. Specifically, if you add a member to a custom class and attempt to deserialize an object that lacks that member, the runtime will throw an exception. In other words, if you add a member to a class in version 3.1 of your application, it will not be able to deserialize an object created by version 3.0 of your application.

Now... As curious as I am I went and created a project, serialized a class, added a new member and attempted to deserialize the class to the new object. To my surprise it worked and the newly created member was set to null by default (even if it had another default value).

[Code]...

View 3 Replies

DB/Reporting :: Deserializing XML Into Object?

Apr 3, 2008

I am now trying deserialize my employee objects in my XML document into an instance of a class.Here is the class I wish to create an instance of:

Code:
Public Class EmployeeAdder
#Region "Declarations"
Private _ID As Int32 = 0
Private _Name As String = String.Empty

[code].....

View 4 Replies

Deserializing Json Array Into .net Class?

Feb 16, 2010

I'm having problems deserializing some json data, getting InvalidCastExceptions and the like.

Can anyone point me in the right direction?

Here's the json i'm wanting to deserialize;

[{"OrderId":0,"Name":"Summary","MaxLen":"200"},{"OrderId":1,"Name":"Details","MaxLen":"0"}]

Here's my code;

[Code]...

View 3 Replies

Ignoring Assembly Info When Deserializing

Feb 5, 2011

I'm writing a solution in VB.NET that consists of a number of different components (UI manager, Outlook add-in, etc.). In the main UI program I'm serializing out an arraylist to a data file that contains the data the other components will need to do their jobs. That part works fine, and I can serialize and deserialize with no problem. Now I want to read (deserialize ) in the data in my Outlook add-in, and I ran into the dreaded 'Unable to find assembly' issue where it's looking for the original assembly that serialized the data. I found a hint for workaround

[Code]...

View 2 Replies

Jquery :: WCF Not Deserializing JSON Input?

Feb 21, 2011

I have a WCF service defined as follows:

Imports System.ServiceModel
Imports System.ServiceModel.Web
<ServiceContract()>

[code].....

View 1 Replies

Serializing/Deserializing A 2- Dimensional Array

Apr 21, 2009

I have a Problem Serializing and Deserializing a 2-Dimensional Array. I have a 5x5 Integer Array and want it to format it into one String (like Base64) to store it as an Attribute in a XML-File.

To store it i use this code:

CODE:

To Read and Format it i tried following :

CODE:

But Deserialize only Returns an Integer not an Array. How i can Deserialize an complete Array ?

View 8 Replies

Tcp/ip - Consecutive Serialized Objects Not Deserializing?

Mar 28, 2009

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.).

View 1 Replies

VS 2008 Deserializing Part Of A Class

Mar 23, 2010

I'm saving potentially very large amounts of data to disk as a single serialized class. But there is a sub class that I would like to be able to retrieve and write back to the disk without having to read the entire file or write back the entire file. Trust me, my reasons for doing this are good, and the design behind this is more than correct.In VB6 this is very easily done. A single statement gets the portion of the data you want from the front of the file and saves it straight to the Type it belongs to, flawlessly. Likewise, if the dimensions of the data haven't changed, but only the values, then Put can be used to save it right back to the file without disturbing the integrity of the entire file.When needed, the entire file is read into a larger structure, and the entire file is put back, but only when necessary. Most of the time the only information being read from and written to the file are in the first few hundred kilobytes of the file.

Now that I've got serialization working, I'm trying to use it to read (deserialize) only the first member of the class serialized to disk. I haven't been able to find any examples of this anywhere that have lead me toward making the sort of progress I'm hoping for.So I suppose the first question is this: Is it possible to read only part of a serialized class from the open file stream? Specifically, in one case I want to read the first two integers stored in the class. In another case I want to read only the first block (sub class) from the open file stream. In both cases I do not want to read the entire file, but just what I'm interested in starting from block 0. I don't need to write back the integers to the first file, but I do need to write back the block to the second.Assuming that the answer to the above is yes. My second question would then be: How is this done? I want to work with the file stream already open rather than opening and closing file streams over and over.I

View 20 Replies

WCF Not Deserializing JSON / Parameters In Web Service Are Null

Jun 17, 2011

I am having the same issues as per this question: WCF not deserializing JSON input..I am at a loss and desperate for a solution. I have scoured the net for answers, but I have found only this question that matches my exact problem. My datacontract parameter is also nothing when the service starts.I have tried the points of the answer in the question above, but they provide me with no clues (The web service executes OK -I am not getting any exceptions - and I can't see what the deserializer is doing - or not doing as the case may be).I am using POST, due to the size of the nested JSON.If more detailed information is needed, I will provide it on request.[code]

View 2 Replies

Embedded DLL In Another DLL As Embedded Resource?

Mar 13, 2012

I have seen this done in C#, such as here although, I cannot seem to figure out how to do this in VB.NET. For some background, I have created a custom ComboBox control as a .dll, and I need to implement it in another .dll(ArcMap Component)

View 1 Replies

File I/O And Registry :: Serializing And Deserializing An Array Of Collections

Aug 28, 2011

I'm developing a program that captures a bunch of information entered by a user on a tab form into five different structured arrays. I want the data to be saved into a single file and reloaded by the program into a similarly built series of structured arrays through a different form.If I understand the process of serializing collections right, I create a single ArrayList variable to capture each of the five Structured arrays.[code]

1. Do I have to declare one variable of the same type as the one in the first element of the ArrayList, or does having the public variable declared in the Class that's going to take this information already cover that?

2. Once I deserialize into the newly declared Rules ArrayList in the new form, is it a simple matter of setting the duplicated variables in the new form equal to the relevant element in the ArrayList? For example, if I have a new Public Roster As RosterDesc variable declared, can I set it equal to Rules(0) and it would automatically populate every element in the same order as they were created in the original form?

View 5 Replies

Json - JavaScriptSerializer() Deserializing Dictionary Array Members

Dec 4, 2011

I am trying to deserialize a JSON string that looks like so: {'type':'clientlist','client_list':[]} I am using JavaScriptSerializer() to do it. For some reason the JavaScriptSerializer() is choking on the member 'client_list'. It doesn't give very good info. The error it gives is:

[Code]...

View 1 Replies

.net - Deserializing XML With Dynamic Types / Converting String To System.Type?

Jun 5, 2009

I'm not sure if i titled this question properly or am asking it properly, but here goes.I've got serialized objects (in XML) stored in a database, along with a string/varchar indicating the type.

[Code]...

View 3 Replies

Deserializing XML Into Simple .NET Class - Cannot Populate Property From Root Node Attribute

Feb 17, 2010

I have a simple class that I trying to populate from an XML document. The XML file has an attribute called TrackingID in the root node which I would like to get as a property. For some reason, when I deseralize the class, the TrackingID is null. Everything else populates fine. I have tried various attributes on the TrackingID property with no luck.

[Code]...

View 1 Replies

Variable That Never Loses Its Value?

Jun 22, 2010

I sometimes need to retain the values of my variable for a very long time as the same value will get used over and over again until it gets referenced again somewhere down the line and then it changes it value.

So is it possible for a variable to never lose its value even when a form is closed or a sub finishes?

View 9 Replies

Combobox Loses Text Value

Mar 1, 2011

I am using VS 2008 to develop a VB application which has a tabcontrol. On the 3rd tabpage is a combobox, set with DropDownStyle as "DropDown" to allow free text to be entered as well as selecting from the loaded items. My application allows for values to be saved to disk and reloaded.

What I'm finding is that when then application is 1st started, if the tabpage containing the combobox has not yet been accessed, and a value is loaded from disk by the application into the combox's text property ( I have verified this using by Debug.Print statement, and using a Watch), when the tabpage containing the combobox is selected (I add a break on the "TabControl1_SelectedIndexChanged" event to check the text value) the text value is cleared to equal "".

[Code]...

View 2 Replies

USB Device Loses Connection?

Apr 19, 2011

Working on supporting a application that connects a digitizer pad to a application. The client said that when the screen saver activates on their computers the digitizer pad looses connectivity and when the screen saver is turned off the pad will not re-sync.Where might i find how to resolve this? We are using the USBAPI provided in visual Basic.net. should we build in consideration for this, or should the API understand connectivity?

View 4 Replies

VS 2008 Send An Object Instead Of Strings Which Includes Multiple Unsigned Integers And Strings

Aug 13, 2009

I am working on a UDP Client/Server, and currently i have them sending back and forth strings, which i convert to bytes, and then open the bytes to read. I want to now send an Object instead of those strings, which includes multiple unsigned integers and strings.

View 39 Replies

AcceptChanges: DGV Loses Selected Rows

Aug 19, 2011

I've got a DataGridView that has a DataTable as the DataSource. If the user has rows selected in the DataGridView, calling AcceptChanges on the DataTable will clear the selection (highlight) from those rows. Can this be prevented?

View 6 Replies

Asp.net Control Loses Its Property Values?

Jun 3, 2009

I'm writing a custom user control for my asp.net site, for storing datetimes. It has two properties:

Private _includeTime As Boolean
Private _value As DateTime = Nothing
Public Property IncludeTime() As Boolean

[code]....

I call my custom control in this way:

<my:DateTimeInput runat="server" includetime="true" ID="txtWhen" />

This sets the includetime property correctly.In my backend code I also do this on page_load:

txtWhen.SelectedDateTime = now

When I step through with the debugger, I see that the property gets set, BUT when the page_load of the control itself loads, the property value is reset to nothing!

The page_load of the control:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lbltime.Visible = IncludeTime
If SelectedDateTime().CompareTo(Nothing) > 0 Then

[code]....

View 2 Replies

Database Loses The Stored Information?

May 7, 2011

I am working on login and registration page in vb express 2010. I have connected access 2007 database with my project and when I register as a user, it stores information to the database successfully and I can log in with that id as well. But when I close that project and reopen it, the same exact id won't work and the information in the database disappears.

View 1 Replies

Form Loses Focus After A Messagebox?

Feb 13, 2012

I have a form which contains a progressbar and a Listbox which update as the code runs through and performs some sometimes time-consuming calculations.

At one point in the code, it breaks to ask the user to enter a number using :

Usedefault = MsgBox("Do you want to use the default value of " & Default_No & "?", vbYesNo)
If Usedefault = vbNo Then

[Code].....

this works fine but I find that once the data entry is complete, and the code continues to run, the form loses focus and the progressbar and the Listbox updates cannot be seen until the code finished its calculations.

View 1 Replies

Graphics.DrawImage Loses Resolution?

Dec 21, 2010

Graphics.DrawImage loses resolution

View 13 Replies

Print Dialog Loses Focus

May 4, 2011

I have a form with a "print" toolstrip button. When I click that button I run the code shown below. The print dialog box appears. The title is dark blue seeming to indicate it has focus. The main form is lighter blue indicating it does not have focus. But hovering over the "Print" button (or the cancel button) does not cause it to change color. If you click on the print button, then the color changes and the second click causes the appropriate action. Same with the cancel button. If you click on the dialog label or on the main form the only thing that happens is the print button will then become "active" and a click there then works. If you click on the main form once, nothing happens, but if you click on it a second time you get the "bonk" sound indicating you ae clicking on the wron modal. As if this isn't strange enough, this action just started recently. I made a few unrelated (as far as I can tell) changes, and discovered this action.[code]....

View 15 Replies

C# - Object Being Passed Using Webmethod, Loses Some Values But Not All?

Jun 22, 2011

when calling a webmethod

[WebMethod]
public Profile synchronize(string MID, DeviceUploadData data)

The object DeviceUploadData has many properties, and a few of them are array's. My question is about the array specifically. It loses it's value once it's received on the webmethod end.This is the property inside DeviceUploadData

Private data() As DataObject
Public Property Data() As DataObject()
Get

[code]....

So the DataObject is populated with data, then once passed, on the other end, some of the DataObject properties are no longer populated. I haven't included the other properties in this example.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved