473,383 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Plase help with Deserialization exception

The following code fails with an exception of
"There is an error in XML document (2, 2)." string with an inner exception of "Value cannot be null.\r\nParameter name: input"
string. The inner exception has a strack trace of " at System.Text.RegularExpressions.Regex.Split(String input, Int32
count)\r\n at KMS.Licensing.LicenseBase.Parse() in c:\\kms\\licensing\\common\\licensebase.cs:line 672\r\n at
KMS.Licensing.LicenseBase.set_LicenseBlob(String value) in c:\\kms\\licensing\\common\\licensebase.cs:line 570\r\n at
KMS.Licensing.LicenseBase..ctor(String the_license_blob, Byte[] the_license_signature_blob) in
c:\\kms\\licensing\\common\\licensebase.cs:line 660\r\n at KMS.Licensing.Consumer.License..ctor() in
c:\\kms\\licensing\\consumer\\server\\license.cs:l ine 72\r\n at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read1_License(Boolean isNullable, Boolean checkType)\r\n
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read5_License()" string
static public License Deserialize (Stream stream)
{
License new_license = null;
XmlSerializer xml_serial = new XmlSerializer(typeof(License));

try
{
new_license = (License)xml_serial.Deserialize(stream);
}
catch (Exception ex)
{
throw new ApplicationException("Failure importing license file",ex);
}
finally
{
stream.Close();
}
return new_license;
} /* License Deserialize */

The file that is represented by the stream was just serialized by this code

public void Serialize (Stream stream)
{
XmlSerializer xml_serial = new XmlSerializer(typeof(License));

xml_serial.Serialize(stream,this);
stream.Close();
} /* License Serialize */

Any pointers to the problem would be most appreciated
-------------------------------------------
Roy Chastain
KMSystems, Inc.
Nov 12 '05 #1
3 2056
Hi Roy,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you're trying to deserialize from
an xml document, there is an exception thrown. If there is any
misunderstanding, please feel free to let me know.

Thanks for providing the serialize and deserialize code. But as far as I
can see, the code is correct. So could you please paste your License class
definition and the serialized xml document here? Because according to the
exception message, there might be a field that cannot be null has a null
value in the xml document.

Looking forward to your reply. Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #2
Kevin,
Thanks very much for you comment. It got me to thinking and I realized that things do not work the way I thought. (Not really
sure what I thought....). Anyway, I discovered my problem. The problem was in my class. It was calling RegEx.Split when it
should not have been. I have now changed things and all appears to work.

On Tue, 12 Apr 2005 05:54:55 GMT, v-****@online.microsoft.com (Kevin Yu [MSFT]) wrote:
Hi Roy,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you're trying to deserialize from
an xml document, there is an exception thrown. If there is any
misunderstanding, please feel free to let me know.

Thanks for providing the serialize and deserialize code. But as far as I
can see, the code is correct. So could you please paste your License class
definition and the serialized xml document here? Because according to the
exception message, there might be a field that cannot be null has a null
value in the xml document.

Looking forward to your reply. Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


-------------------------------------------
Roy Chastain
KMSystems, Inc.
Nov 12 '05 #3
You're welcome, Roy. Thanks for sharing your experience with all the people
here. If you have any questions, please feel free to post them in the
community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Linus | last post by:
Hi, I'm having problems with some very simple deserialization code and would appreciate it very much if I could get some help here. The following is the code:...
2
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data....
3
by: Chrigel | last post by:
Hi all, We have problems deseralizing objects previously serialized as XML. This did work fine with .NET 1.1 but since we have installed SP1, deserializing fails (but serializing works). The...
2
by: Dan | last post by:
Serialization is great except that it does not accommodate version changes (adding a property to a class renders it unable to deserialize because an exception is thrown). I think I understand...
2
by: Urs Vogel | last post by:
Hi Let's assume that I have an object_V1 (version 1) serialized to disk. Later, the class for object_V1 will change to object_V2, having some more members. Now, I would like to read my...
1
by: Jim S | last post by:
I have an application where I have to make a tree of objects. To do this, I have my own node class. At certain points in the application, I need to save data. I am having a problem with the...
3
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
1
by: Taiwo | last post by:
I generated a Typed Dataset class including a base64Binary column. This column was specified as a .NET type of Byte() in the class that was auto-generated. I set the value of this property to New...
2
by: Clark Sann | last post by:
I've added a property to one of my classes and now, when I deserialize it I am getting a version mismatch. How to you add or subtract properties in classes that are being serialized /...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.