Friday, July 4, 2008

Breaking Changes for Silverlight 2 Beta 2

Breaking Changes for Silverlight 2 Beta 2 (corrections and additions)

With Silverlight 2 Beta 2 coming out there were a number of changes that will break applications written for older builds of Silverlight. We published a document that listed these changes and how to fix them (Breaking Changes Between Beta 1 and Beta 2) but this document is now a bit out of date due to corrections/additions made after the document was locked down.

Attached is a more complete up-to-date version of this document. To get this attachment, scroll down to the bottom of this post. Note that I've attached a Word 2007 version and a Word 97-2003 version. In addition, below is a list of changes/additions that might differ between this updated document and those that shiped with the SDK. You can use the attached new version of the document to see the correct changes.

1. Controls no longer allow events to bubble up (in other words, controls eat events). Jesse Liberty's blog Who Ate my MouseDown Event? for more information. Also, the section in the breaking changes doc titled RoutedEventArgs.Handled=true Events No Longer Bubble but it is perhaps not very discoverable under that title.

2. A whole bunch DataGrid breaking changes. The changes are to numerous to list in this post. Download the attached Word file to get them. The online version of the breaking changes doc doesn't have this while the loose Word file that ships with the offline SDK does so you may or may not already have this info depending on your source...

3. Wrong URL in the sample crossdomain.xml file. It should look like this:

crossdomain.xml




"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">









4. Calendar/DatePicker Changes section is wrong. It should look like this:



Who Is Affected: Those using DatePicker or Calendar.

Summary

The following changes were made to the Calendar and DatePicker.

Calendar

· [Remove] Style DayStyle

· [Remove] Style MonthStyle

· [Removed] EventHandler DateSelected

· [Added] EventHandler SelectedDatesChanged

DatePicker

· [Remove] ToolTip ToolTip

· [Remove] EventHandler TextParseError

· [Added] EventHandler DateValidationError

· [Removed] EventHandler DateSelected

· [Added] EventHandler SelectedDateChanged

Calendar and DatePicker

· [Remove] bool IsEnabled {get; set;}

· [Remove] DateTime? SelectableDateStart

· [Remove] DateTime? SelectableDateEnd

· [Remove] bool AreDatesInPastSelectable





5. System.ServiceModel.ClientBase Changes section is wrong. It should look like this:



Who Is Affected: Those using System.ServiceModel.ClientBase.Open() and Close() or System.ServiceModel.ClientBase.Dispose().

Summary

System.ServiceModel.ClientBase.Open() and Close() and System.ServiceModel.ClientBase.Dispose() were removed.

Fix Required

Workarounds for code using Open():

· [preferred] Don’t call it: on the first web service call we will automatically do Open asynchronously, so you don’t need to call it explicitly.

· [preferred] Change code to use OpenAsync and the OpenCompleted event

· [less preferred] Cast the proxy to ICommunicationObject and use BeginOpen/EndOpen

· [not recommended] Cast the proxy to ICommunicationObject and use Open()

Workarounds for code using Close():

· [preferred] change code to use CloseAsync. The CloseCompleted event is not usually necessary as you don’t usually need notification when Close completes

· [less preferred] don’t call Close at all. Resources used by the proxy will eventually be reclaimed

· [less preferred] Cast the proxy to ICommunicationObject and use BeginClose/EndClose

· [not recommended] Cast the proxy to ICommunicationObject and use Close()

Workarounds for code using Dispose() or the ‘using’ C# pattern:

· [preferred] change code to call CloseAsync

· [less preferred] see other alternatives for Close() above

6. The following was added to the Miscellaneous API changes section:

· XmlAnyElementAttributes class no longer implements Collection, ICollection, IEnumerable, or IList

· XmlArrayItemAttributes class no longer implements Collection, ICollection, IEnumerable, or IList

· XmlElementAttributes class no longer implements Collection, ICollection, IEnumerable, or IList

· System.Runtime.Serialization.ExtensionDataObject class was removed.

· XmlAnyAttributeAttribute class was removed.

· XmlAttributes.XmlAnyAttribute member was removed.

· CodeIdentifier class was removed.

· CodeIdentifiers class was removed.

· Removed: delegate types XmlSerializationCollectionFixupCallback, XmlSerializationFixupCallback, and XmlSerializationReadCallback

· The following protected members of XmlSerializationReader were removed:

o [remove] protected void AddFixup(Fixup fixup);

o [remove] protected void AddFixup(CollectionFixup fixup);

o [remove] protected void AddReadCallback(String name, String ns, Type type, XmlSerializationReadCallback read);

o [remove] protected void AddTarget(String id, Object o);

o [remove] protected void FixupArrayRefs(Object fixup);

o [remove] protected Int32 GetArrayLength(String name, String ns);

o [remove] protected Object GetTarget(String id);

o [remove] protected Boolean ReadReference(out String fixupReference);

o [remove] protected Object ReadReferencedElement(String name, String ns);

o [remove] protected Object ReadReferencedElement();

o [remove] protected void ReadReferencedElements();

o [remove] protected Object ReadReferencingElement(String name, String ns, Boolean elementCanBeType, out String fixupReference);

o [remove] protected Object ReadReferencingElement(String name, String ns, out String fixupReference);

o [remove] protected Object ReadReferencingElement(out String fixupReference);

o [remove] protected void Referenced(Object o);

o [remove] protected void UnreferencedObject(String id, Object o);

o [remove] protected class CollectionFixup; // removed

o [remove] protected internal class Fixup; // removed

· The following protected members of XmlSerializationWriter were removed:

o [remove] protected void AddWriteCallback(Type type, String typeName, String typeNs, XmlSerializationWriteCallback callback);

o [remove] protected void WriteId(Object o);

o [remove] protected void WritePotentiallyReferencingElement(String n, String ns, Object o, Type ambientType, Boolean suppressReference);

o [remove] protected void WritePotentiallyReferencingElement(String n, String ns, Object o, Type ambientType);

o [remove] protected void WritePotentiallyReferencingElement(String n, String ns, Object o, Type ambientType, Boolean suppressReference, Boolean isNullable);

o [remove] protected void WritePotentiallyReferencingElement(String n, String ns, Object o);

o [remove] protected void WriteReferencedElements();

o [remove] protected void WriteReferencingElement(String n, String ns, Object o);

o [remove] protected void WriteReferencingElement(String n, String ns, Object o, Boolean isNullable);

o [remove] protected void WriteRpcResult(String name, String ns);

7. The Scrollviewer template elements changed.

To fix: Go to the ScrollViewer template documentation or re-generate a new default template in Blend 2.5. This will get you the correct names of the template elements.

8. Can't get UI elements by name if hosted in ContentControl (ScrollViewers etc).

9. You can find a workaround for the removal of the WatermarkedTextBox control here: WatermarkedTextBox for Silverlight 2 Beta 2.