.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

.net 4.0 breaks serialization test - MemoryStream that cannot seek

Posted By:      Posted Date: October 03, 2010    Points: 0   Category :.NET Framework


I'm serializing a Dictionary<string,string> using BinaryFormatter to a class that extends MemorySteam that I call CannotSeekStream (source below).  CannotSeekStream follows the MSDN guidlines for throwing NotSupportedException from a few properties/methods.  In .net 3.5 I can serialize just fine.  In 4.0, I get a NotSupportedException from the Length property.  stacktrace is below.  At a high level, its strange that I cannot serialize to a stream that cannot seek.  Is this a bug in the framework?


at CannotSeekStream.get_Length() at System.IO.MemoryStream.set_Capacity(Int32 value) at System.IO.MemoryStream.EnsureCapacity(Int32 value) at System.IO.MemoryStream.WriteByte(Byte value) at System.IO.BinaryWriter.Write(Byte value) at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Write(__BinaryWriter sout) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteSerializedStreamHeader(Int64 topId, Int64 headerId) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStrea

View Complete Post

More Related Resource Links

Bug? : Sgen breaks web-service serialization

I am using the noaa weather web service and it works fine if I have not run sgen on the assembly. I have sgen disabled in the project settings and instead run it explicitly in the main build. I run sgen using the command: sgen /a:myassembly.dll /force /compiler:/keyfile:myassembly.snkThis creates an [assembly_name].XmlSerializers.dll and when running the application again, the same call to the web-service fails with the following exception. This is internal to the web-service code so I'm stuck for what to do other than not run sgen:System.InvalidOperationException: There was an error generating the XML document. ---> System.ArgumentException: Item has already been added. Key in dictionary: 'myassembly.gov.weather.www.productType' Key being added: 'myassembly.gov.weather.www.productType' at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections.Hashtable.Add(Object key, Object value) at System.Xml.Serialization.XmlSerializationWriter.AddWriteCallback(Type type, String typeName, String typeNs, XmlSerializationWriteCallback callback) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.InitCallbacks() at System.Xml.Serialization.XmlSerializationWriter.GetTypeEntry(Type t) at System.Xml.Serialization.XmlSerializationWriter.WriteReferencedElement(String name, String ns, Object o, Type ambientType)

Test your skill in SQL Server

You will be given a series of 10 SQL Server related questions that are randomly selected. Since the questions are randomly selected, you will receive a different set of questions each time you start a test. At the end of the last question, you will be given your score. You can then start a new test session if you like.

Test Run: Fault Injection Testing with TestApi


Fault injection testing is the process of deliberately inserting an error into an application to determine whether it deals with the error properly. We'll explain how you can introduce faults into .NET applications at run time using the Managed Code Fault Injection APIs of the TestApi library

James McCaffrey

MSDN Magazine August 2010

Test Run: Generating Graphs with WPF


A common software-development task is generating a graph from a set of test-related data. But if you're doing it by hand and the underlying data changes frequently, this particular task can become quite tedious. James McCaffrey shows you how to automate the process using Windows Presentation Foundation technology.

James McCaffrey

MSDN Magazine June 2010

Test Run: Combinations and Permutations with F#


Understanding combinations and permutations is a fundamental skill in software testing. We show you how to work with combinations and permutations using code written in the new F# language.

James McCaffrey

MSDN Magazine May 2010

Test Run: Testing Silverlight Apps Using Messages


Silverlight greatly simplifies the process of building rich Web applications, and we'll walk through an example of using Messages as a quick method of interactively testing simple Silverlight apps.

James McCaffrey

MSDN Magazine March 2010

Test Run: WCF Service Testing with Sockets


There are many ways to test WCF services, but the socket-based approach is flexible and very useful for security and performance testing. We show you show you how to test a WCF service using a network socket based approach.

James McCaffrey

MSDN Magazine February 2010

Test Run: Web Application HTTP Request-Response Test Automation with JavaScript


Write a simple browser-based request-response test automation using JavaScript that's platform independent and useful when you are working in a highly dynamic environment.

James McCaffrey

MSDN Magazine January 2010

Generation Test: Automated Unit Tests for Legacy Code with Pex


Creating and maintaining a unit test suite for legacy code can be a challenge. Pex automatically produces a small test suite with high code and assertion coverage.

Nikhil Sachdeva

MSDN Magazine December 2009

Test Run: Pairwise Testing with QICT


In this month's column, James McCaffrey explains exactly what pairwise testing is and provides you with complete C# source code for a production quality pairwise testing tool named QICT.

James McCaffrey

MSDN Magazine December 2009

Test Run: Partial Anitrandom String Testing


This column presents an approach to Antirandom (AR) testing the author calls partial AR string testing, which can be used to test a wide range of software systems.

James McCaffrey

MSDN Magazine October 2009

Test Run: Request-Response Testing With F#


This month we show you how to use F# to perform HTTP request-response testing for ASP.NET Web applications.

James McCaffrey

MSDN Magazine July 2009

Test-Driven Design: Using Mocks And Tests To Design Role-Based Objects


Use Test-Driven Development with mock objects to design object oriented code in terms of roles and responsibilities, not categorization of objects into class hierarchies.

Isaiah Perumalla

MSDN Magazine June 2009

Test Run: .NET Module Testing with IronPython


This month we demonstrate how easy it is to use IronPython to test .NET-based libraries.

James McCaffrey

MSDN Magazine June 2009

Test Run: Automating UI Tests In WPF Applications


This month we describe techniques for automating UI testing in Windows Presentation Foundation applications.

James McCaffrey

MSDN Magazine March 2009

Test Run: Analyzing Project Exposure And Risk Using PERIL


Here James McCaffrey uses some statistical methods and a technique he calls PERIL to estimate risks to software projects involving timing, costs, and other potential resource shortfalls.

Dr. James McCaffrey

MSDN Magazine January 2009

Test Run: Configuration Testing With Virtual Server, Part 2


Because Virtual Server is built upon a set of COM modules, you can automate the creation and testing of virtual machines. Here we use Windows PowerShell to run the tests.

Dr. James McCaffrey and Paul Despe

MSDN Magazine December 2008

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend