Xcopy Deployment of a Windows Forms Application
- 5 minutes to read
In this lesson, you will learn how to deploy a Windows Forms XAF application using the Xcopy Deployment method. This method is named after the xcopy command-line utility, which copies files from one location to another. With this method, you copy the application files from the Developer Workstation to a location accessible to end-users.
Instead of the xcopy utility, you can use Windows Explorer or another file manager to copy files. However, in certain cases, the command-line utility may be more convenient than graphical user interface (GUI) tools. To learn more about the xcopy command capabilities, refer to the xcopy document.
Perform the following steps at the Developer Workstation to prepare the Windows Forms application for Xcopy Deployment.
Open the MySolution solution in Visual Studio. In the Solution Explorer, expand the MySolution.Win\References folder. Select assemblies whose names start with "DevExpress". If you use Entity Framework, third-party controls or modules, select their assemblies as well. In the Properties window, set the CopyLocal property to True.
Repeat this step for all module projects that are referenced in the application project (e.g. MySolution.Module and MySolution.Module.Win).
Change the Active Solution Configuration from Debug to Release.
- Build and run the Windows Forms application.
- Check to make sure that the application performs correctly and close it.
Ensure that the MySolution\MySolution.Win\bin\Release folder contains application files.
Now, the Windows Forms application is ready for Xcopy Deployment.
Perform the following steps at an End-User Workstation or at a Terminal Server.
- Ensure that an appropriate version of the Microsoft .NET Framework is installed.
Create an application folder. For instance, it can be C:\Program Files\MySolution. Copy the MySolution\MySolution.Win\Bin\Release folder contents from the Developer Workstation to the newly created directory via the network or using removable media.
As a Windows Forms application project has references to several module projects (e.g. MySolution.Module.Win and MySolution.Module), then it is required to deploy referenced assembles of these modules. Copy required assemblies from output folders of module projects (i.e. MySolution\MySolution.Module.Win\Bin\Release and MySolution\MySolution.Module\Bin\Release). You can skip overwriting files that are copied already.
- Create a subfolder in the application folder. The subfolder name should be the language culture code (for instance, "de" for the German language).
- Copy the required satellite assemblies to the subfolder.
Check to make sure that the target language is added to the application configuration file (MySolution.Win.exe.config)
<appSettings> <!-- ... --> <add key="Languages" value="en;de" /> <!-- ... --> </appSettings>
The supported languages are specified via the Languages key. This key value consists of supported language codes, separated by semicolons.
If there are several localization languages, repeat these steps for each language.
- Create a desktop shortcut to the C:\Program Files\MySolution\MySolution.Win.exe file. Name it MySolution.
Run the application by double-clicking the MySolution.Win.exe file or its shortcut. If the following error message stating that an assembly is missing is displayed, then the reported assembly was not copied to the Release folder from the Developer Workstation Global Assembly Cache (GAC).
To resolve this error, copy the required assembly to the application folder on the target computer. There are two locations on the Developer Workstation where you can get the required assembly.
- %PROGRAMFILES(x86)%\DevExpress 20.2\Components\%PROGRAMFILES(x86)%\DevExpress 20.2\.NET Core Desktop Libraries\Bin\Framework
- %PROGRAMFILES(x86)%\DevExpress 20.2\Components\%PROGRAMFILES(x86)%\DevExpress 20.2\.NET Core Desktop Libraries\Bin
You can register the required assembly in the Global Assembly Cache, instead of copying it to the application folder.
Run the application once again, and determine if there is another missing assembly. Copy it from the Developer Workstation. Repeat the process until there are no error messages concerning missing assemblies.
Note that an error message may look like the following.
The cause of this error is also a missing assembly, but it is not clear which assembly is missing. To find out which assembly it is, open the application log file. This is a text file located in the application folder or in the user's application data folder, and has the most recent modification time. Find the text matching the error message and analyze what happened before the error.
As you can see in the image, in this instance the application was trying to load an assembly when the error occurred. So, it should be copied from the Developer Workstation.
Only run-time assemblies from the Developer Workstation are required. Ensure that you do not accidentally copy design-time assemblies or XML files that are named identically to the run-time assemblies.
Finally, the application will display the following message.
It means that all assembly requirements are satisfied and the application now requires a proper connection string in its configuration file, as well as access to its database. The Set Up the Database Connection lesson describes how to resolve this issue.
If you experience problems performing any steps of this lesson, refer to the Deployment Troubleshooting Guidelesson.
Copy the C:\Program Files\MySolution folder and the MySolution desktop shortcut to each of the remaining End-User Workstations, if necessary. If you are deploying a Windows Forms application to the Terminal Server, follow the steps from the Connect Clients to the Terminal Server lesson.
Now your application needs a connection to a database to run properly. Proceed to the Set Up the Database Connection lesson to learn how to do it. To familiarize yourself with alternative deployment methods, take one of the following lessons.
- Publish Wizard Deployment of a Windows Forms Application
- Setup Project Deployment of a Windows Forms Application