title | description | ms.date | ms.topic | dev_langs | helpviewer_keywords | author | ms.author | manager | ms.subservice | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Download satellite assembly on demand using ClickOnce designer |
Learn how to mark satellite assemblies as optional by using Designer and download only the assembly a client machine needs for its current culture settings. |
11/04/2016 |
conceptual |
|
|
mikejo5000 |
mikejo |
mijacobs |
deployment |
Walkthrough: Download satellite assemblies on demand with the ClickOnce deployment API using the Designer
Windows Forms applications can be configured for multiple cultures through the use of satellite assemblies. A satellite assembly is an assembly that contains application resources for a culture other than the application's default culture.
As discussed in Localizing ClickOnce Applications, you can include multiple satellite assemblies for multiple cultures within the same ClickOnce deployment. By default, ClickOnce will download all of the satellite assemblies in your deployment to the client machine, although a single client will probably require only one satellite assembly.
This walkthrough demonstrates how to mark your satellite assemblies as optional, and download only the assembly a client machine needs for its current culture settings.
[!INCLUDEndptecclick]
Note
For testing purposes, the following code examples programmatically set the culture to ja-JP
. See the "Next Steps" section later in this topic for information on how to adjust this code for a production environment.
-
Build your project. This will generate satellite assemblies for all of the cultures you are localizing to.
-
Right-click on your project name in Solution Explorer, and click Properties.
-
Click the Publish tab, and then click Application Files.
-
Select the Show all files check box to display satellite assemblies. By default, all satellite assemblies will be included in your deployment and will be visible in this dialog box.
A satellite assembly will have a name in the form <isoCode>\ApplicationName.resources.dll, where <isoCode> is a language identifier in RFC 1766 format.
-
Click New in the Download Group list for each language identifier. When prompted for a download group name, enter the language identifier. For example, for a Japanese satellite assembly, you would specify the download group name
ja-JP
. -
Close the Application Files dialog box.
-
Open the Program.cs file. If you do not see this file in Solution Explorer, select your project, and on the Project menu, click Show All Files.
-
Use the following code to download the appropriate satellite assembly and start your application.
:::code language="csharp" source="../snippets/csharp/VS_Snippets_Winforms/ClickOnce.SatelliteAssemblies/CS/Program.cs" id="Snippet1":::
-
In the Properties window for the application, click the Application tab.
-
At the bottom of the tab page, click View Application Events.
-
Add the following imports to the beginning of the ApplicationEvents.VB file.
:::code language="vb" source="../snippets/visualbasic/VS_Snippets_Winforms/ClickOnce.SatelliteAssembliesVB/VB/ApplicationEvents.vb" id="Snippet1":::
-
Add the following code to the
MyApplication
class.:::code language="vb" source="../snippets/visualbasic/VS_Snippets_Winforms/ClickOnce.SatelliteAssembliesVB/VB/ApplicationEvents.vb" id="Snippet2":::
In a production environment, you will likely need to remove the line in the code examples that sets xref:System.Threading.Thread.CurrentUICulture%2A to a specific value, because client machines will have the correct value set by default. When your application runs on a Japanese client machine, for example, xref:System.Threading.Thread.CurrentUICulture%2A will be ja-JP
by default. Setting it programmatically is a good way to test your satellite assemblies before you deploy your application.