Silverlight 2 Readme Notes for Developers
The language version of Silverlight Tools 2 (for example, English) must match a language version of Visual Studio 2008 that you are using.
The Silverlight Tools installer will block installation if any beta or preview versions of Expression Blend are installed.
If you want to use Team Foundation Build server in order to build Web Applications that contain Silverlight 2.0 projects, you must install Visual Studio 2008 and Silverlight Tools 2 on the Team Build Server computer.
The Silverlight Version 2 Software Development Kit (SDK) supports building solutions by using the command line. However, in order to build a solution that contains a Web Application, Visual Studio 2008 SP1 or Visual Web Developer Express Edition 2008 SP1 must be installed, and the Silverlight Tools 2 add-on must be installed as well.
When you build Visual Basic Silverlight projects by using Visual Studio 2008 SP1, the code files are generated with the following warning:
Namespace or type specified in the Imports 'System.Windows.Hosting' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
This error message does not affect your application, and you can ignore it.
When you create a Silverlight application, you might see an error such as the following:
The project file C:\users\someuser\appdata\local\temp\a0pzodsv.om4\temp\silverlight\SilverlightProject2.csproj’ cannot be opened. The project type is not supported by this installation.
A possible cause is that one of the Web projects or Silverlight packages has been disabled. This can happen if a previous version of Silverlight tools has not been uninstalled. To fix the problem, close Visual Studio, open a Visual Studio command line prompt, and then run the command devenv.exe /resetskippkgs.
If the Build output path option is changed from “ClientBin\” to a path that contains non-ASCII characters, the Testpage.html page will be rendered as a blank page at run time.
Visual Web Developer Express Edition only partially installs the Windows SDK, and by default it does not support building non-neutral resource files. If you attempt to build a project that contains non-neutral resources, the build process displays the following error:
Task failed because "AL.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "AL.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A.
To resolve the issue, try one of the following:
· Install the Microsoft Windows SDK for Windows Server 2008 and the .NET Framework 3.5.
· Install Visual Studio 2008.
· Manually set the registry key referenced in the error message to the correct location.
· Pass the correct location into the ToolPath parameter of the task.
Using non-ASCII characters for Silverlight project names is not supported by the Silverlight runtime.
The following APIs cannot be used at design time (in Expression Blend or in the WPF designer for Visual Studio) if you do not have .NET Framework 3.5 SP1 installed:
· System.PlatformID.MacOSX
· System.PlatformID.Xbox
· System.String.Compare(String, Int32, String, Int32, Int32, CultureInfo, CompareOptions)
· System.String.Compare(String, String, CultureInfo, CompareOptions)
· System.Threading.WaitHandle.WaitAll(WaitHandle[], Int32)
· System.Threading.WaitHandle.WaitAll(WaitHandle[], TimeSpan)
· System.Threading.WaitHandle.WaitAny(WaitHandle[], Int32)
· System.Threading.WaitHandle.WaitAny(WaitHandle[], TimeSpan)
· System.Threading.WaitHandle.WaitOne(Int32)
· System.Threading.WaitHandle.WaitOne(TimeSpan)
· System.Net.WebClient
· System.Net.Sockets.Socket
The workaround is to avoid using these APIs at design time, or to install the .NET Framework 3.5 SP1. Note that these APIs are supported at run time even if the .NET Framework 3.5 SP1 is not installed.
Isolated Storage cannot be used at design time (that is, in Expression Blend or Visual Studio's WPF designer). To programmatically determine whether a control is running in design mode, use the System.ComponentModel.DesignerProperties class, as shown in the following example:
using System.ComponentModel;
using System.IO.IsolatedStorage;
using System.Windows.Controls;
public partial class MyUserControl : UserControl {
public MyUserControl() {
InitializeComponent();
if (!DesignerProperties.GetIsInDesignMode(this)) {
// Load data from Isolated Storage
InitializeFromStorage();
}
else {
// Use design-time data
textBlock.Text = "Design Time";
}
}
// Isolated Storage APIs must be called from a separate
// method, otherwise the JIT will throw an error
private void InitializeFromStorage() {
textBlock.Text =
IsolatedStorageSettings.ApplicationSettings["Foo"];
}
}
If a Silverlight control is not rendered in a Web page that is served by IIS, the likely cause is that the .xap file type is not registered as a MIME type that IIS will serve. You must manually register the MIME type of application/x-silverlight-app for the file extension .xap in the IIS management console. For information about how to register a MIME type, see the article IIS 6.0 does not serve unknown MIME types on the Microsoft Help and Support Web site.
If you set any filters for local Help in Visual Studio, some Silverlight documentation is hidden. To ensure that all of the Silverlight documentation is visible, do the following:
1. In the Table of Contents pane or the Index pane, set Filtered by to "(unfiltered)".
2. In the Search tab, set Language, Technology, and Content Type to "All".
If you right-click a Silverlight project and select the Add Service Reference option to add a reference to a Web service in a localized installation of the Silverlight Tools 2, some warning messages in the Error List window might appear in English.
To resolve the issue, follow these steps:
1. From the Windows Start menu, open Microsoft Visual Studio 2008 and then open Visual Studio Tools.
2. Right-click Visual Studio 2008 Command Prompt and then click Run as administrator.
3. In the Command window, navigate to the following path:
%ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Tools\ServiceReference\zh-Hant
In the command, replace zh-Hant with the correct language name for your Silverlight Tools 2 installation.
4. Run the following command:
gacutil /i Microsoft.Silverlight.ServiceReference.Resources.dll
5. Restart Visual Studio.
Whenever a new Silverlight runtime version becomes available, you will be prompted to upgrade to that version. However, if you are using the Macintosh developer runtime, installing from the upgrade prompt will replace the developer runtime with the end-user runtime. Therefore, when you are prompted to upgrade, click Remind Me Later. Then download and install the latest Macintosh developer runtime manually.
If you receive the following error when trying to debug an application running on a Macintosh, it is likely because you do not have the Silverlight Runtime for Developers installed:
0x80131C3C (CORDBG_E_DEBUG_COMPONENT_MISSING)
If you select a control on the Toolbox and try to drag or draw the control on the Silverlight Preview window (which looks like a design surface), nothing happens. This is because the window is only a preview; it is not an interactive design surface. A future release will make this difference clearer.
To work with Silverlight controls on a design surface, drag them from the Toolbox directly into the XAML editor window.
If you use data binding to populate your controls, the data might appear only at run time.
Workaround: Currently there is no workaround for this issue.
If you rename the App.xaml file, you might see errors like Cannot find a Resource with that Name/Key in the Error List window for references to resource keys that are defined in App.xaml.
Workaround: Do not rename the App.xaml file.
Occasionally, if a build is progress and you attempt to open a XAML file, an exception is thrown.
Workaround: Wait for the build to finish before you open a XAML file. Alternatively, refresh the Preview window.
If you create a custom control with write-only properties, the control throws exceptions when it is displayed in the Preview window.
Workaround: Always include a get accessor for custom control properties.
After you rename a resource in the App.xaml file, you might expect to see errors reported immediately in other XAML documents that reference the resource. However, the error does not appear until after you save the modified App.xaml file and after you reload the XAML documents that use the resource.
If a user control fails to load, the Preview window reports an error as Unknown attribute <name> on <control> (user control). The attribute that is referenced is not important; the message simply means that the control cannot be loaded, which might be due to a variety of reasons.
Third-party controls fail to load
When a third-party control is installed on the Toolbox, under some circumstances it can fail to load the first time it is added to the project. Controls sometimes include additional assemblies that contain support code, and in some circumstances these additional assemblies are not discovered by the Toolbox.
When you drag the control from the Toolbox to the XAML editor, Visual Studio adds a project reference for the control assembly, but not for the support assemblies. However, after the complete set of references is added to the project, the control will load and the project will build successfully.
Workaround: Refer to the control's documentation to determine which assemblies are required by the control, and manually add references to these assemblies.
A StaticResource object that is both defined and referenced inside the same element will cause the Preview window to fail to load and returns the following error:
The type StaticResource was not found.
Workaround: Move the static resource to the App.xaml file.
Occasionally, when the Preview window or XAML View opens, an error is displayed. This can occur if the last instance of the Preview window was closed and reopened without rebuilding the project. To work around this issue, try the following:
· Always leave open at least one view of a XAML document in your project.
· Rebuild the project.
· If your project will not build, close and reload the project, or close and reopen Visual Studio.
Adding a prefix within a TargetType property for a resource defined in App.xaml results in an Invalid attribute value… error in the Error List window. In addition, the designer preview will be empty for any XAML file in the project.
Workaround: Move the style or template that defines the TargetType property to Page.xaml.
The following example shows an App.xml file that does not work:
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="FF2.App"
xmlns:extended="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls">
<Application.Resources>
<Style x:Key="DatePickerStyle" TargetType="extended:DatePicker">
<Setter Property="Margin" Value="10"/>
</Style>
</Application.Resources>
</Application>
Page.xml (fails to load)
<UserControl x:Class="FF2.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:extended="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
FontFamily="Trebuchet MS" FontSize="11"
Width="800" Height="Auto">
<StackPanel>
<extended:DatePicker Style="{StaticResource DatePickerStyle}"/>
</StackPanel>
</UserControl>
The previous App.xml file results in the following error:
Error 1 Invalid attribute value extended:DatePicker for property TargetType. [Line: 99 Position: 51] E:\Projects\Temp\FF2\Page.xaml 1 1 FF2
The following example shows an App.xml file that works correctly:
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="FF2.App"
xmlns:extended="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
>
<Application.Resources>
</Application.Resources>
</Application>
Page.xml (loads correctly)
<UserControl x:Class="FF2.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:extended="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
FontFamily="Trebuchet MS" FontSize="11"
Width="800" Height="Auto">
<UserControl.Resources>
<Style x:Key="DatePickerStyle" TargetType="extended:DatePicker">
<Setter Property="Margin" Value="10"/>
</Style>
</UserControl.Resources>
<StackPanel>
<extended:DatePicker Style="{StaticResource DatePickerStyle}"/>
</StackPanel>
</UserControl>
Silverlight lets you override the default splash screen (and progress indicator) that is displayed before an application starts. However, the custom splash screen must be a XAML file with Silverlight 1.0 markup. It must also use the Silverlight 1.0 programming model, which is based on JavaScript event handlers. The runtime does not support .xap files or Silverlight 2 markup for the splash screen.
The Host.Source property does not function when Silverlight is hosted outside of a browser, such as on the visual design surface within Visual Studio. Attempting to use this property outside the browser can result in an AccessViolationException error.
The element tree of the Silverlight application manifest can be created only by the runtime. If application code attempts to pass the contents of AppManifest.xaml to the XamlReader.Load method and then cast the results to a Deployment object, a Use the Current property to access the Deployment instance error is thrown. This indicates that the Deployment object is a singleton.
As a workaround, use XmlReader to parse the dynamically loaded manifest. This provides similar functionality, but does not provide the same strong typing.
When you manually download and install the Silverlight runtime on Windows, if the installer is run from a path that contains characters that are not in the current Windows ANSI character set, the installation will fail during file extraction.
If calls to WebClient.DownloadStringAsync, WebClient.UploadStringAsync, or WebClient.OpenWriteAsync result in the server returning an error code (such as 404 - Not Found), the associated completion event will be raised. However, the Error property of the EventArgs object will not be filled. Instead, the Result property will be either null or String.Empty.
If the OpenWriteCompletedEventArgs.Result stream is used in a handler for WebClient.OnOpenWriteCompleted, and if the stream is closed before any data is written to it, an IndexOutOfRangeException will be thrown and the upload will not be sent to the server.
If you call Close on the upload stream provided by WebClient.OpenWriteCompleted or HttpWebRequest.BeginGetRequestStream after the stream has already been closed, it will incorrectly throw an ObjectDisposedException error.
The runtime currently supports only ASCII characters in file names in an application. You cannot use non-ASCII characters in an image, media, or XAML file name in your project. The build system does limited validation for invalid characters in file names. However, if your project contains references to remote resources (outside the XAP) with non-ASCII names, the application will build successfully, but might fail at run time. Similarly, if you use non-ASCII type names in your project, the build system might not raise an error, but your application will fail at run time. The only workaround is to change file names to use ASCII characters.
When you specify a font family by using the FontFamily property of TextBlock, Run, or Control elements (or elements derived from them), only English font-family names are supported. If you try to use a localized font-family name, content will not be rendered with the correct font.
In Silverlight 2, the TextBox control supports IME Level 3. There are a few issues that might have a minor affect on using an IME in the TextBox control. For example, sometimes the candidate window is not in the correct location. However, in general these issues do not affect conversion results of an IME in the TextBox control.
To render some East Asian characters correctly, you must specify the language for the XAML by setting xml:lang attribute. This attribute is inherited by child elements. Therefore, you can set it on the root element, on a control that displays text, or on a text element such as a TextBlock control.
System.Globalization.CultureInfo uses culture data provided by the operating system. Some operating systems do not provide access to certain CultureInfo properties. In that case, InvariantCulture data is used instead. For example, Windows does not provide data for the MonthDay pattern, so the pattern of the invariant culture is used instead.
The Visual Basic DateString returns dates in MM-dd-yyyy format except when the CurrentCulture setting for the thread is set to an East Asian culture. In these cases, the function uses the yyyy-MM-dd format, which provides default behavior that is similar to that of Visual Basic when it runs in desktop applications on East Asian systems. The documentation incorrectly states that the Silverlight Visual Basic DateString formatting behavior is based on the system locale instead of on the CurrentCulture setting.
Silverlight 2 replaces the Beta 1 MIME type with a new MIME type that is specific to Beta 2. If you use the object element to instantiate the Silverlight plug-in, use the Beta 2 MIME type and the associated Installer URL, as listed in the following table.
|
Version |
MIME Type |
Version |
Installer URL |
|
Silverlight 1.0 |
application/x-silverlight |
1.0 |
|
|
Silverlight 2 Beta 1 |
application/x-silverlight-2-b1 |
2.0.30226 |
|
|
Silverlight 2 Beta 2 |
application/x-silverlight-2-b2 |
2.0.30523 |
http://go2.microsoft.com/fwlink/?LinkID=115261
|
|
Silverlight 2 (RTW) |
application/x-silverlight-2 |
2.0.30923 |
The following table lists examples of the object element templates.
|
Version |
Template |
|
1.0 |
<object type="application/x-silverlight" data="data:application/x-silverlight," ...> . . . <a href=http://go2.microsoft.com/fwlink/?LinkID=110408 style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /> </a> </object> |
|
2B1 |
<object type="application/x-silverlight-2-b1" data="data:application/x-silverlight-2-b1," ...> . . . <a href="http://go2.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /> </a> </object> |
|
2B2 |
<object type="application/x-silverlight-2-b2" data="data:application/x-silverlight-2-b2," ...> . . . <a href=http://go2.microsoft.com/fwlink/?LinkID=115261 style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /> </a> </object> |
|
RTW |
<object type="application/x-silverlight-2" data="data:application/x-silverlight-2," ...> . . . <a href=http://go2.microsoft.com/fwlink/?LinkID=124807 style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /> </a> </object> |
Although you can install the Silverlight 2 SDK English on a computer that also has the Silverlight 2 SDK Beta 2 Japanese installed, this scenario is not recommended.
If you have installed both Silverlight 2 SDK and Expression Blend, and if you then remove either one, you must repair the other product in order to restore the SDK registries. To repair the SDK, run the installer and choose the option to repair. You can find the SDK installer on the Getting Started page of the Silverlight Web site.
Visual Studio users can view only one set of Silverlight documentation at a time. By default, this will be the documentation of the language of the last Silverlight SDK that was installed.
To enable a specific Silverlight documentation set in Visual Studio, repair the corresponding language SDK from the SDK installer. To merge the documentation Help collection in Visual Studio, follow the instructions provided in the Welcome page of the SDK.
The Silverlight Tools for Visual Studio 2008 release adds the MediaPlayer and Silverlight controls to the Silverlight tab in the Visual Studio Toolbox. When you drag these controls onto a page, the System.Web.Silverlight assembly is copied to the Bin folder of the Web site.
Adding these controls to the Bin folder is not compatible with Web sites that have been created with ASP.NET 3.5 Extensions project templates from the ASP.NET 3.5 Extensions Preview (released December 2007). If you have installed the ASP.NET 3.5 Extensions Preview, uninstall it, and replace any 3.5 Extensions Web sites with standard Web site projects. It is also recommended that you uninstall any previous versions of Silverlight Tools for Visual Studio 2008. If necessary, refresh the Visual Studio Toolbox after uninstalling the release by right-clicking the Toolbox and then clicking Reset Toolbox.
To register ASP.NET Web server controls with Visual Web Developer Express Edition 2008 SP1, follow these steps.
1. In Visual Web Developer Express Edition 2008 SP1, open an ASP.NET Web page (.aspx file).
2. Right-click the Toolbox and then click Add Tab.
3. Name the new tab Silverlight.
4. Right-click the area under the tab and then click Choose Items.
5. In the .NET Framework Components tab of the Choose Toolbox Items dialog box, click Browse.
6. Browse to the path that contains the assembly with the Silverlight controls, select System.Web.Silverlight.dll, and then click Open.
By default, the path is the following:
Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Server
7. In the list of controls, select the MediaPlayer and Silverlight controls, and then click OK.
When you use the server-side part of the HTTP Polling Duplex channel (System.ServiceModel.PollingDuplex.dll) on the .NET Framework 3.5 SP1 or on the .NET Framework 3.0 SP2, you might encounter a thread and memory-leak issue. The issue is that the server gradually uses more and more threads and memory without ever releasing these resources, which eventually results in an unstable condition. The problem does not occur on .NET Framework 3.5 without a Service Pack, or on the .NET Framework 3.0 SP1.
In many scenarios, a workaround is to restart the process that is hosting the Polling Duplex service at some regular interval, such as every 12 hours. (The exact interval you use depends on service load.) If you are hosting the Polling Duplex service in IIS, you might be able to work around the issue by isolating the service in a separate application pool and then configuring the Application Pool Recycling settings correctly.
The issue will be addressed in a future release. If this issue is blocking you from using the HTTP Polling Duplex channel in a production application, contact Microsoft Product Support Services to discuss your options, which can include the possibility of requesting an earlier fix.