Implementation Differences Between Silverlight and Silverlight for Windows Phone
Microsoft Silverlight will reach end of support after October 2021. Learn more.
This topic describes feature implementation differences between Silverlight on Windows Phone and Silverlight 4 on other platforms. This topic also describes some differences between Silverlight on Windows Phone OS 7.0 and Windows Phone OS 7.1.
The following topics also provide additional information about Silverlight for Windows Phone.
For a summarized list of supported and unsupported features, see Features Differences Between Silverlight and Silverlight for Windows Phone.
For detailed information about unsupported types and members, see Class Library Support for Windows Phone.
The following sections in this topic provide detailed information about Silverlight for Windows Phone.
Controls
Deep Zoom
Delegates
Finalizers
Fonts
Generic Types
Graphics
Hosting
Input
I/O
Isolated Storage
LINQ
Localization
Media
Multitouch and Manipulation Events
Navigation
Networking
Paths
Performance
Reflection
Regular Expressions
Runtime
Screen Resolution
Security
SIP
Silverlight Extensions for Windows Phone
Streams
Strings
Threads
URIs
XAML Transformations
XML
XNA Framework
Other Differences
Controls
For information about supported and unsupported controls, see Controls in Silverlight for Windows Phone.
Deep Zoom
Silverlight for Windows Phone always uses hardware acceleration on a MultiScaleImage image, if possible. As a result, any change you make to the CacheMode property of MultiScaleImage is ignored.
Delegates
Asynchronous delegate calls, specifically the BeginInvoke and EndInvoke methods, are not supported in Silverlight for Windows Phone. Consequently, the following code is not supported:
AsyncCallback callback = new AsyncCallback(result);
callback.BeginInvoke();
Some exceptions are different in Silverlight for Windows Phone when using delegates:
If you attempt to invoke delegates asynchronously, the application throws TargetInvocationException instead of NotSupportedException.
Delegate.CreateDelegate throws MissingMethodException while trying to create a delegate with incorrect arguments. On Windows, the method does not throw an exception; it returns null.
Delegate.CreateDelegate throws TargetInvocationException when called on a null object.
Delegate.CreateDelegate throws MissingMethodException instead of ArgumentException for non-instance methods.
A multicast virtual function lookup delegate throws NullReferenceException in Silverlight for Windows Phone, while AccessViolationException is thrown in Silverlight.
Finalizers
Constrained execution regions (CERs) are not supported in Silverlight for Windows Phone.
Fonts
For information on supported fonts in Silverlight for Windows Phone, see Fonts in Silverlight for Windows Phone.
Generic Types
When you specify a generic type you can specify a maximum of 64 generic type parameters. If you are using generics types with LINQ to SQL, you can use nested queries to work around this limitation.
Graphics
The graphics threading architecture in Silverlight for Windows Phone is optimized for devices. For information on the threading architecture and how to improve graphics performance, see Graphics in Silverlight for Windows Phone.
In Silverlight for Windows Phone, effects such as BlurEffect and DropShadowEffect are not supported.
Custom pixel shaders are not supported, so the PixelShader type is not supported.
For additional information about graphics and animation in Silverlight, see the following topics.
Hosting
Silverlight applications on Windows Phone are hosted on the client device and do not run inside of a browser. Silverlight features that are based on a browser host are not supported. These features include the HTML DOM bridge, JavaScript programmability, and the Silverlight plug-in object reference.
Input
Controls that are supported on Windows Phone are gesture-aware, and support gestures such as tap, double-tap, hold, pan, and flick.
For additional information on input differences between Silverlight on Windows and Windows Phone, see Input in Silverlight for Windows Phone.
For information on using manipulation events to respond to touch input, see How to: Handle Manipulation Events.
I/O
For information on platform differences associated with I/O streams, see Streams in this topic.
Isolated Storage
Isolated storage allows applications to store data in a virtual file system. The data is completely isolated from other system components. This prevents unauthorized access and data corruption by components other than the application that is storing the data.
As in Silverlight on Windows, the data is automatically deleted when you uninstall the associated application on the Windows Phone. The data is retained in other scenarios, including a device or application update, or a device restart.
Isolated storage on Windows Phone does not enforce quotas to restrict the size of isolated storage for Silverlight-based applications. The default quota size of 1 MB does not apply.
Implementation differences between Silverlight on Windows Phone and Silverlight on Windows include the following:
Isolated storage on Windows Phone does not include the concept of a site; therefore, GetUserStoreForSite is not supported.
IncreaseQuotaTo throws an exception.
When you call BeginRead or BeginWrite in a Windows Phone application, the operation is executed synchronously. If you need to write a large amount of data and do not want to interrupt the UI thread, you can create a new thread and perform the operation on that thread.
In the IsolatedStorageFileStream class constructor, FileShare.Delete and FileShare.Inheritable are not supported because of a platform limitation. Passing a value of Delete will cause a IsolatedStorageException.
The default quota size returned to an application is MAXLONG.
IsolatedStorageSettings is not thread safe and throws an IsolatedStorageException when Save() is called.
When using isolated storage, strings that contain wild card characters or regular expression are not supported when passed as input if the string also contains a filename or a directory name.
For information about isolated storage in Silverlight, see the following topics:
LINQ
LINQ query providers for custom data sources are not supported in Silverlight for Windows Phone.
LINQ to XML
The following limitations apply to LINQ to XML support:
When you use XML serialization on objects of type XElement, extra XElement tags are added to the beginning and end of the XML content.
The XmlSerializer.Serialize method throws an InvalidOperationException if the XmlSerializer object is initialized with a type parameter that contains an array of objects of type XElement.
The constructor for the XmlSerializer object throws an InvalidOperationException if the XmlSerializer object is initialized with a type parameter that contains two XElement members and both are marked with the XmlAnyElementAttribute.
Expression Trees
ArrayIndex throws an ArgumentNullException when ConstantExpression and Expression is passed.
Parameter does not throw an ArgumentException as expected when passed a void type.
LambdaExpression.Compile is not supported in Windows Phone SDK.
Silverlight for Windows Phone throws an exception while trying to create a new object using a lambda expression that targets expression trees. For example,
Expression <D1> d = () => new N(); will compile, but fails at runtime.
Localization
Support for globalization is based is based on the cultures and regions supported by the underlying platform. For additional information, see Creating Globally Aware Applications. For information on culture names supported on Windows Phone, see Globalization and Localization Overview for Windows Phone.
Some of the types and members that support localization behave differently on Silverlight for Windows Phone, as follows:
A custom culture returns standard formatting when custom formatting is expected. For example, 31/08/2006 12:30:15 Afternoon! returns as 8/31/06 12:30:15 PM.
You cannot use a neutral culture in formatting and parsing; therefore you cannot set a neutral culture as the thread's current culture.
DateTimeFormatInfo.ShortTimePattern values do not change when the clock is set to 24 hours. The property values should become "h:mm" but remain "h:mm tt" where tt is AM or PM.
ToString() does not return the expected value for a null format and Invariant Culture.
DateTimeFormatInfo.GetEra returns -1 for the fr-FR culture.
new CultureInfo(“fr”).DateTimeFormat.AMDesignator throws a NotSupportedException.
DateTimeFormatInfo.GetEraName method returns incorrect values in some cases. For example, the fr-FR localization string DC is returned when A.D is expected.
DateTime.ToString does not return the correct string for Russian dates. For example, 15.Июнь.2000 is returned instead of 15.июня.2000.
System.DateTime.Now.Millisecond.ToString always returns zero on the Windows Phone Emulator.
Double.ToString does not return the correct string containing comma delimiters between group digits when a custom format is used.
ResourceManager.GetSatelliteContractVersion returns a random version number instead of the expected value.
String comparison operations for strings containing trigraphs may not work as expected for cultures where trigraphs are used, such as "dzh" in the culture hu-HU. For example, IndexOf(String, String, CompareOptions) and IsSuffix(String, String, CompareOptions) may return an incorrect result.
The constructor, ResourceManager(String, Assembly, Type), throws NotSupportedException when the usingResourceSet parameter is null.
ResourceManager.GetObject does not throw an exception when the object is missing in the resource file.
Some localization exceptions thrown by applications are different in Silverlight for Windows Phone:
If you attempt to use unsupported East Asian languages, the application throws PlatformNotSupportedException instead of TypeInitializationException.
If you pass an invalid culture for the satellite assembly in Assembly.GetSatelliteAssembly(CultureInfo), the method throws a FileNotFoundException on Windows Phone. Also, if you pass InvariantCulture, the Assembly.GetSatelliteAssembly(CultureInfo) method returns an en-US satellite assembly instead of throwing a FileNotFoundException.
CompareInfo.Compare does not throw the expected exception, ArgumentException, if you pass an invalid CompareOptions object.
If you set CultureInfo("fr").NumberFormat.CurrencySymbol to "USD", it throws NotSupportedException.
CultureInfo.CultureInfo(String) constructor throws PlatformNotSupportedException instead of ArgumentException for unsupported cultures.
Serializing Custom attributes on Estonian culture (et-EE) culture does not work properly.
The DateTime.ParseExact method accepts an incorrect time instead of throwing FormatException, while on Windows FormatException is thrown, which indicates that the time was not a valid DateTime.
Media
For information about media implementation differences between Silverlight on Windows and Silverlight on Windows Phone, see Media in Silverlight for Windows Phone.
Multitouch and Manipulation Events
To enable multitouch and manipulation events, Silverlight for Windows Phone supports types, members, and events that are not present in Silverlight 4. For additional information, see How to: Handle Manipulation Events.
For information on input differences between Silverlight on Windows and Windows Phone, see Input in Silverlight for Windows Phone.
Navigation
Silverlight for Windows Phone provides a different page navigation model than Silverlight on Windows. The Frame and Page classes are not supported. The implementation of these classes and some navigation-related events such as the FragmentNavigation event, are provided in the Microsoft.Phone assembly instead of the System.Windows.Controls.Navigation assembly. For additional information, see the Frame and Page Navigation topic in Windows Phone Development.
In Windows Phone OS 7.1, if you use the NavigationEventArgs(Object, Uri) constructor to create a NavigationEventArgs and pass null for the uri parameter, when you later access the Uri property, it will be an empty Uri.
Networking
For information about networking implementation differences between Silverlight on Windows and Silverlight on Windows Phone, see Networking in Silverlight for Windows Phone.
Paths
On Windows Phone, Environment.CurrentDirectory and Environment.GetFolderPath have a SecurityCriticalAttribute attribute, because Silverlight for Windows Phone is based on Silverlight. This attribute restricts this member to internal use. Application code that uses this member throws a MethodAccessException.
Some path-related exceptions thrown by applications are different in Silverlight for Windows Phone:
If you pass an invalid path in GetDirectoryName, the method does not throw an exception. For example, System.IO.Path.GetDirectoryName(@"D:\temp\ .") returns "D:\temp" instead of throwing an exception.
GetDirectoryName does not throw any exception when the source path is longer than the system-defined maximum path length.
GetPathRoot returns an empty string when the input is prefixed with whitespace.
System.IO.Path.GetPathRoot(String.Empty) returns a null string instead of throwing an ArgumentException.
System.IO.Path.GetPathRoot(@":hello") returns a null string instead of throwing an ArgumentException.
Performance
Silverlight for Windows Phone supports a composition thread for certain graphics animation and access to the graphics processing unit (GPU). For information on optimizing graphics performance using this architecture, see Performance Considerations in Applications for Windows Phone and Graphics in Silverlight for Windows Phone.
Note: |
---|
The frame rate counter in Silverlight for Windows Phone is different than the frame rate counter on Windows. For additional information, see Graphics in Silverlight for Windows Phone. |
To optimize XAML code when applying multiple transformations, Silverlight for Windows Phone supports CompositeTransform.
For Silverlight performance tips, see Performance Tips.
Reflection
Reflection implementation differences between Silverlight on Windows and Windows Phone are as follows:
Reflection is always case-sensitive. If you attempt to perform a case-insensitive type search by calling the Type.GetType(String, Boolean, Boolean) method and passing true for the ignoreCase parameter, a NotSupportedException is thrown.
Some types and members are not supported in Silverlight for Windows Phone. For a list of unsupported methods, see Class Library Support for Windows Phone.
Open generics, which are generic types or methods that do not have instantiable types substituted for all its type parameters, are not supported in Silverlight for Windows Phone. The following operations are exceptions to this and are supported:
Returning an open generic type or method by calling Type.GetType() or Type.GetMethods.
Creating a constructed type from an open generic type or method by calling Type.MakeGenericType or MethodInfo.MakeGenericMethod.
Behavior and functional differences exist between the binder implementation in Silverlight and Silverlight for Windows Phone.
GetPublicKeyToken returns null instead of byte[0] for a byte[0] PKT or for an assembly name containing PublicKeyToken=null.
AssemblyName.ToString and Assembly.FullName return System.Reflection.AssemblyName when the default constructor was used to instantiate the AssemblyName object.
AssemblyName.FullName does not return PublicKeyToken information by default. Silverlight for Windows Phone only provides the assembly name. You must use individual methods to compare the culture, version, and PKT information.
For the declaringType parameter, GetMethodFromHandle(RuntimeMethodHandle, RuntimeTypeHandle) uses RuntimeMethodHandle instead of RuntimeTypeHandle.
The equality (==) operator for two equal MethodInfo objects does not return true in Silverlight for Windows Phone.
FieldInfo.ToString() returns System.Boolean[] instead of Boolean[] when it points to a bool.
GetValue(Object, BindingFlags, Binder, array<Object[], CultureInfo) throws ArgumentException when the index parameter is a string value and binder is not the default binder.
In Silverlight for Windows Phone, the ignoreCase parameter is not supported on Type.GetType(String, Boolean, Boolean). You must use case-sensitive type names.
Type.GetNestedTypes(BindingFlags) returns all nested types irrespective of the BindingFlags value.
In Silverlight for Windows Phone, DefaultValue returns null.
Type.GetMember method does not return any public members with the specified name if the name string is a regular expression.
Type.GetMethods and Type.GetMembers methods do not return the same object instance.
Type.GetMethod(String, array<Type[]) returns a null MethodInfo value for the Set(Int32, System.String) method while desktop returns a MethodInfo value, which is not necessarily null.
The return value for Type.AssemblyQualifiedName is not the same between Silverlight for Windows Phone and . For example, the return value for AssemblyQualifiedName on Silverlight for Windows Phone might look like this: MyType, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089. In , the equivalent return value might look like this: MyType, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=B17A5C561934E089.
Some exceptions thrown by reflection-based applications are different in Silverlight for Windows Phone:
If you invoke a static constructor using reflection, the application throws ArgumentException instead of MethodAccessException.
Assembly.GetType throws TypeLoadException instead of ArgumentException when the string value is null.
If you pass an invalid string to Load, it throws IOException instead of ArgumentException.
LoadFrom fails when you try to load a file that is not a valid assembly. This behavior is by design; the failure occurs during metadata validation to prevent loading of a corrupt image.
If the assemblyFile parameter is not a valid assembly, the LoadFrom(String) method throws IOException instead of BadImageFormatException.
If you pass an invalid name toAssembly.GetType(String), the method does not throw ArgumentException, but instead returns a null type.
If you pass an invalid culture for the satellite assembly in Assembly.GetSatelliteAssembly(CultureInfo), the method throws FileLoadException on Windows, but it throws a FileNotFoundException on Windows Phone.
If you pass an invalid string toAssemblyName(String) constructor, the constructor throws FileLoadException instead of IOException.
ConstructorInfo.Invoke throws ArgumentException instead of TargetParameterCountException when there is a mismatch in the number of arguments.
EventInfo.AddEventHandler throws ArgumentNullException instead of TargetException when passing null as the first parameter or eventinfo is not declared on target
AddEventHandler(Object, Delegate) throws ArgumentNullException instead of InvalidOperationException when the event does not have a public add accessor.
FieldInfo.GetValue throws an ArgumentNullException when null is passed as first parameter.
If you useFieldInfo.SetValue on a field that is defined as both public and constant, the method throws MemberAccessException instead of FieldAccessException.
FieldInfo.SetValue throws an ArgumentNullException instead of TargetException when null is passed as the first parameter.
FieldInfo.SetValue(Object, Object) throws InvalidCastException when casting an object's field info value to a string using string instead of ToString.
MethodBase.GetMethodFromHandle does not throw any exception when an invalid handle is passed as input. Instead, it returns null.
Acquiring the type using the ReturnParameter property from a MethodInfo object throws NotSupportedException.
Module.GetType does not throw ArgumentException when an empty string is passed as name of the type. Instead, it returns null.
If you pass an invalid parameter toModule.ResolveMethod, the method throws ArgumentException instead of ArgumentOutOfRangeException.
If you pass invalid values toPropertyInfo.GetValue, the method throws an ArgumentNullException instead of TargetException.
If the count of indexes is less than the real count, PropertyInfo.GetValue throws ArgumentException instead of TargetParameterCountException.
If you pass a null object to CreateInstance, the method throws NullReferenceException instead of NotSupportedException.
For types that do not have constructors defined, Activator.CreateInstance(Type, array<Object[]) throws MemberAccessException instead of MissingMethodException.
When you attempt to set a non-integer value to an integer field of a base class through a derived class, Type.InvokeMember throws MissingFieldException instead of ArgumentException.
When the current type object contains open type parameters, Type.InvokeMember(String, BindingFlags, Binder, Object, array<Object[]) throws NotSupportedException instead of InvalidOperationException.
Some attribute constructor arguments and property values can cause Type.GetCustomAttributes to fail.
Type.MakeByRefType does not throw TypeLoadException when the MakeByRefType method for a ByRef type is called.
Type.GetProperty throws NullReferenceException instead of ArgumentNullException when the array representing the parameter types contains a null element.
Type.GetConstructor(BindingFlags, Binder, array<Type[], array<ParameterModifier[]) throws ArgumentNullException when no ParameterModifier types are specified (NULL is passed). On Windows, no exception is thrown.
If you pass an invalid parameter toType.GetType(String, Boolean), the method throws a TypeLoadException instead of an ArgumentException.
Type.GetType(String, Boolean) returns an ArgumentException instead of a null type when the typeName parameter is empty.
Type.GetMethods throws InvalidProgramException if one of the methods contains a type will not be available at runtime.
Type.InvokeMember throws MissingFieldException when the name argument contains a wildcard character.
The Type.Missing field does not throw ArgumentException when the called method has no default value for a parameter.
If you pass a string to Version.CompareTo, the method throws InvalidCastException instead of ArgumentException.
Regular Expressions
In Silverlight for Windows Phone, the CacheSize property always returns zero because the Regex class implementation does not support caching.
If you pass an invalid value to MatchCollection.CopyTo(Array, Int32), the method throws ArgumentOutOfRangeException instead of ArgumentException.
Runtime
Silverlight for Windows Phone runs on the .NET Compact Framework. Applications written for previous versions of Windows Phone or for .NET Compact Framework 3.5 or earlier are not supported on Windows Phone.
Screen Resolution
Windows Phone applications typically must support different screen resolutions for orientation changes. For application design tips, see Designing a Flexible User Interface.
Security
The following differences apply to X509 certificates:
- If you pass an invalid X509KeyStorageFlags value when you create an X509Certificate, a NotSupportedException occurs instead of ArgumentException.
SIP
To enable you to set the software input panel (SIP) on a TextBox control, Silverlight for Windows supports several types and members that are not present in Silverlight. For more information, see How to: Specify On-Screen Keyboard Layout for a TextBox.
Silverlight Extensions for Windows Phone
For additional features that are specific to Windows Phone development, see the Class Library Reference for Windows Phone. These features are included in the Windows Phone SDK.
Streams
The following differences apply to the use of streams:
If you pass an invalid input path to a StreamWriter constructor, the constructor throws InvalidArgumentException instead of DirectoryNotFoundException.
StreamWriter.Write and StreamReader.Read may throw IndexOutOfRangeException if the stream state becomes corrupted. On Silverlight for Windows Phone, the stream state may become corrupted if multiple threads read from or write to a stream object without using synchronization.
ArrayTypeMismatchException is not thrown when your application tries to store Stream.Null in a variable of type MemoryStream.
ArgumentNullException is thrown when trying to retrieve a MemoryStream of size zero bytes from a resource file. On Windows, no exception is thrown and length is equal to zero.
Strings
A StringBuilder object can allocate more memory as needed as characters are added to the object. The amount of memory allocated is implementation-specific, and an OutOfMemoryException is thrown if the amount of memory required is not available. If an alternative to StringBuilder is needed, open a MemoryStream and write strings to the memory stream instead of using the StringBuilder class.
If you call Replace when a null character exists in the string, the new string will be truncated at the first null character.
The String.IndexOf method returns incorrect output when the string contains Unicode characters.
The String.LastIndexOf(String, Int32, StringComparison) method returns incorrect values when the string contains Unicode characters.
The StartsWith(String, StringComparison) method returns incorrect values when the string contains Unicode characters.
Threads
Unlike Silverlight, Silverlight for Windows Phone splits animation work on two different threads for better performance on devices. For additional information, see Graphics in Silverlight for Windows Phone.
Array.Sort(Array) is not thread safe.
ThreadStaticAttribute is not used by the Silverlight for Windows Phone.
WaitAll is not supported in Silverlight for Windows Phone.
The 64-bit members of the Interlocked class are present but not supported.
URIs
In Silverlight for Windows Phone, the HttpUtility class is in the System.Net namespace. On Windows, this class is in the System.Windows.Browser namespace, which is an unsupported namespace on Windows Phone.
LocalPath does not convert the forward slash (/) to a backslash (\). This is because file-based URIs (URIs of the form file://) are not allowed. Paths returned are relative paths.
The OriginalString property for a Uri instance trims any leading space before the scheme in the URL.
XAML Transformations
To optimize XAML when you are applying multiple transformations, Silverlight for Windows Phone supports CompositeTransform.
XML
Parse is not supported in Silverlight for Windows Phone because Silverlight for Windows Phone does not support document type definitions (DTDs). The application throws a NotSupportedException when it encounters a DTD string in XML. To parse DTDs, an application must either implement this feature or use XML schemas.
The following differences also apply to Silverlight for Windows Phone:
Using System.Xml.Serialization.XmlSerializer to serialize and deserialize classes associated with LINQ to XML such as XElement and XName is not supported.
The serialized output of an XmlSerializer object of type XmlQualifiedName is not well-formed.
Wrapping a custom reader is allowed in Silverlight for Windows Phone. That is, you can create a custom reader with your own implementations of the required functions, and then pass the custom reader as input to XmlReader.Create(XmlReader, XmlReaderSettings).
Some XML exceptions thrown by applications are different in Silverlight for Windows Phone:
Wrapping a custom reader does not result in an InvalidOperationException. Applications must make sure the ConformanceLevel in XmlReaderSettings is set to Auto when wrapping a custom reader.
DataContractSerializer.ReadObject throws MethodAccessException instead of MessageSecurityException when it attempts to deserialize an IXmlSerializable type that has a private constructor.
DataContractSerializer.WriteObject fails when it tries to serialize an inner type that contains a type derived from Dictionary<TKey, TValue> because open generics are not supported.
For DataContractSerializer class constructors that include an IEnumerable parameter, if the type passed in the knownTypes parameter is an implementation of the interface specified by the type parameter, and the interface is not public, Silverlight for Windows Phone throws a MessageSecurityException. On other platforms, serialization occurs with no exception thrown.
XmlReader does not fail when numeric character entity computation overflows. Instead, an empty string is returned to the Value property.
Message.ToString() shows different behavior on Windows Phone. Message.ToString() does not show XML version information in Silverlight for Windows Phone.
LineNumber and LinePosition values are incorrectly returned in XmlException.
XNA Framework
XNA Framework for Windows Phone and Silverlight for Windows Phone are dependent on .NET Compact Framework for base class library support. Most of the supported types and members are the same. For additional information, see XNA Framework and Silverlight.
Other Differences
Additional implementation differences in APIs are as follows:
When you try to create circular nested generic classes, a TargetInvocationException is thrown. You cannot create a circular nested generic class in Silverlight for Windows Phone.
Classes in the System.Collections namespace do not throw ArgumentNullException when a null parameter is passed to the constructor. For example, Dictionary<object, object>.ValueCollection valueCollect = new Dictionary<object, object>.ValueCollection(null) does not throw ArgumentNullException.
GetHashCode returns equal values for different methods of the same class.
GetHashCode returns zero for some user-defined structs in Silverlight for Windows Phone, but non-zero values in .NET Framework.
Decimal.Parse returns an invalid decimal value when exponents are used for values near zero. On Windows, the method returns zero. For example, for the values 0E-50 and 10900E-512, an invalid decimal value is returned instead of zero.
The value of Math.Sin(Math.PI/2) is 0.99999999999999989. The value on Windows is 1.
Some methods throw different exceptions in Silverlight applications on Windows versus Windows Phone. The following information describes this behavior on Windows.
Silverlight for Windows Phone throws OverflowException instead of AmbiguousMatchException when a resource file is invalid.
Silverlight for Windows Phone throws an exception when deriving a class from Dictionary<TKey, TValue> where the key parameter is an enumeration.
If your application attempts to invoke a non-existing method of a type, or tries to invoke a method that has ambiguity, Silverlight for Windows Phone throws AmbiguousMatchException.
If you pass an invalid value to Array.SetValue(Object, Int32), the method throws InvalidCastException instead of ArgumentException.
Array.GetLowerBound does not throw IndexOutOfRangeException when the passed in dimension is equal to the rank of the array. Instead, it returns zero as the lower bound value.
ArgumentException displays the message Argument Exception instead of Exception of type 'System.ArgumentException'. Similarly, ArithmeticException displays Arithmetic Exception instead of the string that is thrown on Windows.
ICollection.CopyTo throws ArgumentException instead of InvalidCastException.
The display message for MissingMethodException is incorrect.
If you pass an invalid code page name to Encoding.GetEncoding, the method throws PlatformNotSupportedException instead of ArgumentException.
Decimal.Parse returns 0 for infinitesimally small values on Windows, but returns OverflowException on Windows Phone.
Decimal.Parse(String, NumberStyles) throws OverflowException if you pass a larger than supported value. No exception is thrown on Windows.
If you pass an invalid parameter toString.IndexOfAny, the method throws ArgumentOutOfRangeException instead of ArgumentNullException.
See Also