Create a Vuser Script in Visual Studio

LoadRunner Professional's basic IDE add-ins for Visual Studio let you create a Vuser script in Visual Studio in VB, C++, or C#.

Develop a script in Visual Studio

To create your script, you first install the Visual Studio add-in. Then use one of the predefined templates.


  • Visual Studio must be installed in the default location.
  • We recommend installing UWP (Universal Windows Platform) 2017 or 2019 before installing the add-in LRVS2017IDEAddInSetup.exe or LRVS2019IDEAddInSetup.exe.

To develop a Vuser script in Visual Studio:

  1. Install the IDE add-in for your version of Microsoft Visual Studio from your LoadRunner Professional installation package's Additional Components folder. For example, Additional Components\IDE Add-Ins\LRVS<version>IDEAddInSetup.exe.

  2. In Visual Studio, select the appropriate template from the Installed Templates LoadRunner VB|C++|C# .NET Vuser. Visual Studio creates a new project with one class and a template for a Vuser, and the script file, <name>.usr. The template contains three sections, Initialize, Actions, and Terminate.

    The following example shows a Visual C# template:

    public int Initialize()
              // TO DO: Add virtual user's initialization routines
                return lr.PASS;
          public int Actions()
              // TO DO: Add virtual user's business process actions
              return lr.PASS;
          public int Terminate()
              // TO DO: Add virtual user's termination routines
              return lr.PASS;
  3. Add code to the template, in the TODO sections.

  4. Open the Object Browser (View menu). Expand the LoadRunner node (for example Interop.LoadRunner) to see the LoadRunner Professional elements. Add the desired elements to your script, such as transactions, rendezvous points, and messages.

  5. Expand the Toolbar menu, Vuser, and enhance your script with runtime settings and parameters. For more information, see the runtime settings General > Run Logic or the Parameter List dialog box.

  6. Use the Vuser menu to replay the script and test its functionality.

  7. Select Vuser > Create Load Scenario, to create a LoadRunner Professional scenario using this .usr file.

  8. You can also build the LoadRunner Professional project as a DLL file, which will be saved in the same folder as the project. You can reference this DLL directly from a LoadRunner Professional scenario.

Back to top

Known issues

Visual C++ language When using the 2015/2017/2019 add-ins for Visual Studio, the Visual C ++ language must be installed in order to work with C++ .NET Vuser projects.
Register .NET assembly

When using Visual Studio and add-ins to create C# and VB .NET scripts, Visual Studio creates .NET assemblies that need to be registered in the system before their run. Registration of the .NET assembly requires administrative permissions.

Resolution: Enable UAC and register the .NET assembly before running the test using one of these methods:

  • Run Visual Studio "As Administrator" and provide administrative credentials when prompted. In Project Settings, ensure that the Register for COM interop option is set (Project > Properties > Build > Register for COM interop). Visual Studio will automatically register the test DLL as a .NET assembly every time it builds the project.
  • Run Visual Studio without administrative permissions, and manually register the test DLL after it is built. To do so, run Windows Console with administrative permissions and run the following command: %WINDIR%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe <TargetDLLwithPath> /codebase (ignore the warning issued when you run this command).

    For example, you might replace <TargetDLLwithPath> with c:\users\qatest\documents\visual studio 2015\Projects\LoadRunnerUser1\LoadRunnerUser1\LoadRunnerUser1.dll. You do not need to register the DLL after every build. It is enough to register it once after making changes in the COM interfaces defined in the DLL.

VB project

If you have an issue creating a VB project in Visual Studio 2017 or 2019, use this workaround:

  1. Create a VBVBWizards folder under ..\Microsoft Visual Studio\<version>\Enterprise.
  2. Copy the folders 1033 and LrVbVuserClass found under ..\Microsoft Visual Studio\<version>\Enterprise\VB\VBWizards, and paste them into the VBVBWizards folder.
  3. Restart Visual Studio. The VB project should now be created successfully.


Although .NET-based and Java protocols support creating threads, we recommend that you do not use background threads in real load testing scenarios because:

  • Threads can degrade tests scalability.

  • Threads can affect performance measurements.

  • The utility functions' behavior is undetermined if called from any thread except the Vuser main thread which runs the vuser_init, Action, and vuser_end actions. This applies to all functions named lr*.

Back to top

See also: