In order for a .NET application that contains Measurement Studio components to run properly on a target machine, the target machine must contain certain Measurement Studio components.
Microsoft Visual Studio makes distribution much easier by providing Setup and Deployment projects. Setup and Deployment projects allow you to create an installer in order to distribute an application. The resulting Windows Installer (.msi) file contains the application, any dependent files, information about the application such as registry entries, and instructions for installation. Note:
Visual Studio 2012 and later do not include the Setup and Deployment projects. If you are using Visual Studio 2012 or later, you will need to complete a different process to distribute your application to another machine. NI recommends using Measurement Studio Installer Builder
when creating new installers. Measurement Studio Installer Builder was released with Measurement Studio 2015. If you do not have access to a version of Measurement Studio with installer builder, NI recommends using the Windows Installer XML (WiX) Toolset
to create an installer from Visual Studio 2012. See Deploying Measurement Studio Applications with WiX
for instructions on deploying your Measurement Studio application using the WiX toolset.
Complete the following steps to create a deployment project that contains the necessary Measurement Studio components using Visual Studio 2003, 2005, 2008, or 2010:
- Open an existing Visual Studio project or example program. This should be the project you want to deploy to another machine.
- Check the target platform for your project by navigating to Build»Configuration Manager
Some National Instruments libraries are platform-specific, meaning that there are separate 32-bit and 64-bit versions of the assemblies. By default, the Measurement Studio project types add references to the 32-bit assemblies. If you have the target platform set to AnyCPU and install your application on a 64-bit operating system, the application will try to load the 64-bit versions of the assemblies, causing a run-time error if you have deployed only 32-bit components. A solution for this is to set the target platform to x86 (32-bit). 32-bit applications will run correctly on a 64-bit operating system, and setting the target to x86 ensures that the application looks for the correct assemblies.
If you want to create a 64-bit application, set the target platform to x64. You will need to replace the references in your project to point to the 64-bit versions of the assemblies. Platform-specific 64-bit assemblies are stored at C:\Program Files\National Instruments\MeasurementStudioVS[Visual Studio version]\DotNET\Assemblies (64-bit)\Current. You will also need to be sure to have the 64-bit merge modules included in your deployment project (see step 7).
Note: Some National Instruments class libraries do not have 64-bit support. For these assemblies, the target platform for the project must be x86. For more information about target platforms, see Measurement Studio Help: 64-bit Support in Measurement Studio .NET Assemblies .
- Build and run the application to verify that there are no errors.
- Add a Setup project to your existing project workspace:
- Open the Add New Project dialog box.
- Visual Studio 2005/2008/2010—Select File»Add»New Project
- Visual Studio 2003—Select File»Add Project»New Project.
- In the resulting Add New Project dialog box:
- Visual Studio 2005/2008/2010—Select Other Project Types»Setup and Deployment»Visual Studio Installer
- Visual Studio 2003—Select Setup and Deployment Projects.
- In the Templates pane, select Setup Wizard.
- In the Name field, give your installer a name. Setup1 is the default name.
- Click OK to close the dialog box and launch the Setup Wizard.
- On the first page of the Setup Wizard, click Next.
- Select Create a setup for a Windows application and click Next.
- Check Primary Output from [Name of Project] and click Next.
- You can add any additional files your application requires, such as text files, requirements documentation, or an .ini file. If you do not need to add any files, just click Next.
- Click Finish.
- After finishing the Setup Wizard, add a Program Files Folder to the installer's target file structure. This will prevent you from getting error -2705 on some target machines.
- The File System ([Name of Setup Project]) window should come up automatically after finishing the Setup Wizard. If it does not, open the File System Editor one of two ways:The File System Editor displays a standard set of folders that represent the folder structure on a target computer.
- Click your Setup1 project in the Solution Explorer to select it, then navigate to View»Editor»File System.
- Double-click Primary Output from [Name of Project] in the Solution Explorer.
- Right-click the File System on Target Machine node and select Add Special Folder»Program Files Folder.
- Check Detected Dependencies in the Solution Explorer to make sure all merge modules have been added for the components in the project. Most of the time, merge modules are automatically detected by Visual Studio. However, in some cases Visual Studio fails to detect them. See Measurement Studio .NET Merge Modules to determine what merge modules are required for the National Instruments libraries and components you are using. If any are missing from the Setup project, right-click the Setup1 project in the Solution Explorer, select Add»Merge Module, and browse to the required file. By default, Measurement Studio installs all merge modules in the C:\Program Files\Common Files\Merge Modules directory.
- Additional merge modules are required if you are using ActiveX controls. Add CWUI_OCX.msm if you are using any of the ActiveX graphs, sliders, or other user interface controls. If you are using the 3D graph control, add CW3DGRAPH_OCX.msm. This will add all of the additional dependencies needed for the ActiveX controls.
- If you are deploying to Windows 7, you may need to add MStudioUtils.msm. See Why Did My Measurement Studio Distribution Not Fully Install In Windows 7? for more information.
- Right-click your Setup1
project and select Rebuild. This builds the installer containing all the dependencies.
- To deploy your files to another computer, open Windows Explorer, navigate to your project directory, and find the built installer. The default path on Windows 7 will be C:\Users\[User Name]\Documents\Visual Studio\Projects\[Solution Folder Name]\Setup1\[Project Configuration]\Setup1.msi
. The [Project Configuration] is either Debug or Release.
- Copy Setup1.msi, Setup.exe, and all other files and sub-directories in the directory to the target computer.
- On the target computer, double-click Setup.exe to run the installer.
You must have install permissions on the target computer in order to run the installer.Note:
If your application uses any National Instruments hardware drivers, such as NI-DAQmx, NI-VISA, or NI-488.2, then you will also need to install the driver itself on the target machine. For some drivers, there is a runtime you can install if you do not want to install the full driver. For example, you can download the NI-DAQmx runtime from ni.com/downloads
. Search for and install the version that matches the version installed on your development machine.
For further information on deploying Measurement Studio applications, refer to the Deploying Measurement Studio Applications
help topic in the Measurement Studio Help
. Measurement Studio Help
can be accessed from within Visual Studio through the Measurement Studio integration menu item.