How to: Debug or Test a LightSwitch Extension

In order to debug a LightSwitch extension, you must install it in a separate instance of Visual Studio. The Visual Studio 2013 SDK provides an experimental instance of Visual Studio for debugging extensions. You must first enable the experimental instance in order to debug.

You can also test an extension—rather than debug it—by installing it in an instance of LightSwitch. If you make subsequent changes to the extension, you must uninstall and then reinstall the extension in order to test the changes.

To enable an experimental instance

  1. In Solution Explorer, choose the BusinessTypeExtension.Vsix project.

  2. On the menu bar, choose Project, BusinessTypeExtension.Vsix Properties.

  3. On the Debug tab, under Start Action, choose Start external program.

  4. Enter the path of the Visual Studio executable, devenv.exe.

    By default on a 32-bit system, the path is C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe; on a 64-bit system, it is C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe.

  5. In the Command line arguments field, enter /rootsuffix Exp.

    Note

    All subsequent LightSwitch extensibility projects will also use this setting, by default.

To debug an extension

  1. On the menu bar in Visual Studio, choose Debug, Start Debugging. An experimental instance of Visual Studio opens.

  2. In the New Project dialog box, expand the Visual Basic or Visual C# node, choose the LightSwitch node, and then choose the LightSwitch Desktop Application template.

  3. In the Name field, enter a name for the test project, and then choose the OK button to create a test project.

    Note

    You can also open an existing LightSwitch application.

  4. On the menu bar, choose Project, ProjectName Properties.

  5. In the Project Designer, on the Extensions tab, select the check box next to your extension to enable it for the current project.

  6. Add data and screens as you deem necessary to test the functionality of your extension. You can set breakpoints in the main instance of Visual Studio to debug the extension when the test application is in either design or run mode.

    Tip

    When debugging control extensions that expose properties, you should test the properties in both the design-time and run-time screen designers.

To test an extension without debugging

  1. On the menu bar, choose Build, Build Solution.

  2. Open the output directory of the .Vsix project, and locate the ProjectName.vsix file. The path resembles \ProjectName\ProjectName.Vsix\bin\Debug, under the folder that contains your solution.

  3. Copy the ProjectName.vsix file to a computer where LightSwitch is installed.

    Note

    This can be the same computer where you are developing the extension.

  4. On the target computer, double-click the ProjectName.vsix file, and in the Visual Studio Extension Installer dialog box, click Install.

  5. Open a new instance of LightSwitch, and then on the menu bar, choose Add, New Project.

  6. In the New Project dialog box, expand the Visual Basic or Visual C# node, choose the LightSwitch node, and then choose the LightSwitch Desktop Application template.

  7. In the Name field, enter a name for the test project, and then choose the OK button to create a test project.

    Note

    You can also open an existing LightSwitch application.

  8. On the menu bar, choose Project, ProjectName Properties.

  9. In the Project Designer, on the Extensions tab, select the check box next to your extension to enable it for the current project.

    Important

    If you make subsequent changes to the extension, you must uninstall it in Extension Manager and then reinstall the new version of the extension.

  10. Add data and screens as you deem necessary to test the functionality of your extension.

    Tip

    When testing control extensions that expose properties, you should test the properties in both the design-time and run-time screen designers.

See Also

Tasks

How to: Create a LightSwitch Extension Project

How to: Set VSIX Package Properties

Concepts

LightSwitch Extensibility Toolkit for Visual Studio 2013