By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,680 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,680 IT Pros & Developers. It's quick & easy.

BUG: DeSerialization with empty byte array

P: n/a

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
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Taiwo" <ta*****@hotmail.com> 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

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.