Why does dataset not serialize its binaryformat property? (Ado.net 2.0)

Source: Internet
Author: User

I have tested the dataset new "binary serialize" feature in ADO. net
2.0. Except articals said if we set the dataset's property
"Remotingformat" as "serializationformat. Binary", it can serialize
Itself in binary format.

OK, this propety works well, the output file is much smaller than XML style.

But I got something strange:
If
I first set a dataset "remotingformat" as "binary" before serialize it
Into a file, then deserialize it to a new dataset, the new dataset's
"Remotingformat" value is missing, it become the default value:
"XML "!!!


Binaryformatter BF =   New Binaryformatter ();
Filestream FS =   New Filestream (system. appdomain. currentdomain. basedirectory. tostring () +   " DS. dat " , Filemode. openorcreate );
Dataset DS = Givemefakedata ();
DS. remotingformat = Serializationformat. Binary;
BF. serialize (FS, DS );
FS. Close ();

// Check the deserialization performance.
FS =   New Filestream (system. appdomain. currentdomain. basedirectory. tostring () +   " DS. dat " , Filemode. Open );
Long Nowticks = Datetime. Now. ticks;
Dataset DS2 = (Dataset) BF. deserialize (FS );

// Note here!
// Ds2.remotingformat = serializationformat. xml!

Long Tickstotal = Datetime. Now. ticks - Nowticks;
Console. writeline ( " Took me: "   + Tickstotal );
FS. Close ();

Then I dig into the source code, I have found

  Private   Void Serializedatasetproperties (serializationinfo, streamingcontext context)
{
Info. addvalue ( " Dataset. datasetname " , This . Datasetname );
Info. addvalue ( " Dataset. namespace " , This . Namespace );
Info. addvalue ( " Dataset. prefix " , This . Prefix );
Info. addvalue ( " Dataset. casesensitive " , This . Casesensitive );
Info. addvalue ( " Dataset. localelcid " , This . Locale. lcid );
Info. addvalue ( " Dataset. enforceconstraints " , This . Enforceconstraints );
Info. addvalue ( " Dataset. extendedproperties " , This . Extendedproperties );
}


It looks like the dataset didn't serialize the remotingformat property.

Anyone knows why it like this? Is it a bug or a design demo?

(Have reported this issue to MS)

Updated: 2005/9/26

The ado.net PM (kawarjit Bedi) has replied this issue:

=== Quote ===

The primary motivation for doing that were:
1. Backward
Compatibility. If a V2.0 client recives dataset from V2.0 server using
Binaryremoting (set at server side-the client does not know it) and
Then sends the same dataset to v1.x client without resetting
Remotingformat property to XML, it 'd break the v1.x client. With
Default behavior, it 'd not break this case.
2. The value
Remotingformat property is a like a parameter being passed to
Remoting engine, it's more to do with the remoting operation then
Dataset's state, hence the reluctance to serialize the property.

=== End quote ===

So, this is not a bug but a design demo.

Thanks kawarjit

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.