Visual Studio Project

Table of contents


Description

This cube is available since version 7.3.2.0

The "Visual Studio Project" action allows you to use a project created in the Microsoft Visual Studio 2019 environment in the ZennoPoster project and thereby opens unlimited possibilities for writing, debugging code and connecting external libraries.

How to add an action to a project?

Via context menu Add Action -> Custom Code -> Visual Studio Project

Or use smart search.

What is it used for?

  • Convenient integration of third-party libraries and their application in code

  • Create your own libraries for reuse in different projects

How to work with an action?

The "Visual Studio Project" action can work in two modes:

  • Using a Visual Studio Solution

  • Using Dll

In the "Use Visual Studio solution" mode, the cube properties look like this

Control elements:

  1. Selecting the mode of working of the cube

  2. The path to the solution where the project is located

  3. The project that will be run when the cube is executed

  4. Project configuration

  5. Flag combining output dll and dependencies into one dll file using ILRepack

  6. Button for switching to the "Use Dll" mode

  7. Connect to Visual Studio button

  8. Create New Visual Studio Project button

In the "Use Dll" mode, the cube properties look like this

Control elements:

  1. Selecting the mode of working of the cube

  2. The path to the dll that will be run when the cube is executed

“Use Visual Studio Solution” Mode

Create a project and connect to Visual Studio

For the action to work in the "Visual Studio Solution" mode, the following must be installed:

Follow these steps to create a project and connect to Visual Studio:

1. Add an action and select the "Use Visual Studio Solution" mode

2. Create a new project by clicking on the button “Create new Visual Studio project” (1)

A window will appear in which you need to fill in the name of the project, location and name of the solution and click "OK"

As a result, the process of creating a Visual Studio solution will start.

And then the process of connecting to Visual Studio.

Connecting to Visual Studio provides interoperability between Project Maker and Visual Studio. This interaction allows:

  • Record actions from the Project Maker browser into Visual Studio source code

  • Debug a Visual Studio project with access to the Project Maker browser and project

After connecting, the Project Maker browser window will open in Visual Studio, if this window did not open automatically, you can call it View → Other Windows → ZennoPosterToolWindow.

Working in Visual Studio, project structure

In order for a project to be used by an action, it must meet the following requirements (projects created from Project Maker already meet all the requirements):

  • Contain links to shared ZennoPoster libraries: Global.dll, ZennoLab.CommandCenter.dll, ZennoLab.Emulation.dll, ZennoLab.InterfacesLibrary.dll. These libraries are located in the ZennoPoster installed folder.

  • Contain a class that implements the IZennoExternalCode interface. When executing the code, the public int Execute (Instance instance, IZennoPosterProjectModel project) method will be called which should return 0 on success and any other value if an error occurs.

The project created automatically contains one Program.cs file, which contains the implementation of the Execute method.

Embedding the Project Maker browser in Visual Studio allows you to record actions in source code. To enable/disable recording, click the “Record” button on the toolbar of the browser window.

To return the browser to Project Maker, click the “Return to Project Maker” button.

When recording is enabled, entering a new url into the browser creates a new action file ActionGroupXXX.cs, where XXX is the end-to-end number of the action set, and the code for calling this action is added to the Program.cs file.

To access a browser or a project, instance and project objects are passed to the Execute method, you can work with them in the same way as described in the C# code section (C sharp code .net)

To debug your code, use the standard “Start” button in Visual Studio.

Using dll

After completing the development of the project in Visual Studio, you can quickly go to the direct use of the output dll, to use the button "Use as dll"

After clicking on this button, a window will open that allows you to select the required actions

  1. Build solution (required step)

  2. Merge into one dll. Merging the output dll and libraries into one dll file using ILRepack (allows you to reduce the number of files that need to be transferred with the project)

  3. Copy dll to the required path (by default, the project folder macro is used)

  4. Select dll for using in this action block. Changing the mode of the cube to "Use dll" and setting the path to the dll

  5. Open result in Explorer

Possible errors and how to fix them

Project Target Framework Not Installed

This error means that the developer kit for .Net 4.6.2 is not installed, it must be downloaded from the official site and installed Download .NET SDKs for Visual Studio Download .NET SDKs for Visual Studio

Call was rejected by callee (RPC_E_CALL_REJECTED)

This error means that Visual Studio is denying interop requests from ProjectMaker. Most often this happens when you need to perform some action in Visual Studio (a dialog box appears), you should switch to Visual Studio and perform the necessary actions there. After that, you should reconnect to Visual Studio. If the error persists, restart Visual Studio, if that doesn't help, contact technical support.

Rendering of cube properties does not work correctly after connecting to Visual Studio

The problem looks like this. Please note that when you click on different cubes or an empty spot in the diagram, the cube properties are not updated correctly.

To fix this problem, you need to check your Visual Studio settings.

English version (Tools → Options… → General):

A detailed description of this setting is available at the link: Per-Monitor Awareness support for Visual Studio extenders

If this option is not available for you, then you should update Windows and Visual Studio, or you can use the instructions for installing the key in the registry:

Disable DPI-awareness in Visual Studio

Useful links