BUG: DeSerialization with empty byte array

  • Thread starter Thread starter Taiwo
  • Start date Start date
T

Taiwo

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
 
Taiwo said:
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.
 
Back
Top