PC Review


Reply
Thread Tools Rate Thread

BUG: DeSerialization with empty byte array

 
 
Taiwo
Guest
Posts: n/a
 
      9th Oct 2003

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 Byte() {} (i.e. Byte
array with zero elements) in a row of an instance of the class prior to
serialization using the binary formatter. When I attempt to DeSerialize the
instance, the following exception is thrown:

[System.Reflection.TargetInvocationException]:
{System.Reflection.TargetInvocationException}
Exception has been thrown by the target of an invocation.

I get around this exception by setting the value of the column to Nothing
(or Null in C#) instead of an empty byte array (New Byte() {}). What is the
problem with DeSerializing an empty byte array in this instance?

--------------------------------
Steps to reproduce bug
--------------------------------
1. Create a typed dataset with at least one column of type base64binary.
Let's call this column b64Binary. Let's call the dataset MyTypedDataset
2. Create a class with one of its properties as type MyTypedDataset
3. Create an instance of the class defined in step 2
4. Add a row to the MyTypedDataset property of the class, making sure to set
the value of the b64Binary column to 'New Byte() {}'. This is a byte array
with zero elements
4. Serialize the instance to memory or disk using the Binary Formatter
5. Now, attempt to DeSerialize the serialized instance. You should receive
the exception:

[System.Reflection.TargetInvocationException]:
{System.Reflection.TargetInvocationException}
Exception has been thrown by the target of an invocation.

My workaround is to set the b64Binary column to 'Nothing' if you're using
VB.NET, or Null if you're using C#.

Thanks,

Taiwo


 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      9th Oct 2003
"Taiwo" <(E-Mail Removed)> schrieb
>
> 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 Byte() {}
> (i.e. Byte array with zero elements) in a row of an instance of the
> class prior to serialization using the binary formatter. When I
> attempt to DeSerialize the instance, the following exception is
> thrown:


Sorry to say that, but I think the description is better placed in a
languagte independent group (somewhere in
microsoft.public.dotnet.framework.*) as this


> ... to Nothing (or Null in C#) ...


statement also shows. Your good description is welcome for sure.


--
Armin

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Value of type byte cannot be converted to 1-dimentional array of byte cmdolcet69 Microsoft VB .NET 3 25th Sep 2007 10:10 PM
How do I convert a ASCII Byte Array, to another Byte Array Russell Mangel Microsoft Dot NET Framework 2 2nd Feb 2005 06:01 PM
Re: Byte Array to Printable String to Byte Array Jon Skeet [C# MVP] Microsoft Dot NET 0 4th Aug 2004 01:53 PM
How to Convert Binary Coded Hex Byte Array to Byte Charles Law Microsoft VB .NET 25 2nd Jun 2004 02:21 PM
Convert native byte array (pointer) to managed byte[] Dave Microsoft Dot NET 1 13th Aug 2003 05:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:47 PM.