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
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)
If you already have a created project, then you can skip the next steps, select the solution, project and configuration in the cube properties and connect to Visual Studio using the button “Connect to Visual Studio” (2)
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.
To connect to Visual Studio, you need the ZennoPosterVisualStudioExtension extension. It will be automatically installed in Visual Studio on the first connection.
If the menu item View → Other windows → ZennoPosterToolWindow is missing, then it is likely that the ZennoPosterVisualStudioExtension is not installed or is disabled. In Visual Studio, open the Extensions -> Manage Extensions window, go to the Installed section and check the status of the ZennoPosterVisualStudioExtension. If the extension is not installed, then try restarting Project Maker and connect to Visual studio again, if the problem persists, then contact technical support.
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.
For the action to work in the "Use dll" mode, the installed Visual Studio is not required. Thus, this mode can be used to transfer the finished project between different computers. In this case, it is necessary to ensure the availability of the required dlls on each computer (for example, copy to the project folder)
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
Build solution (required step)
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)
Copy dll to the required path (by default, the project folder macro is used)
Select dll for using in this action block. Changing the mode of the cube to "Use dll" and setting the path to the dll
Open result in Explorer
You can also manually change the mode and specify the path to the required dll, so that the dll can be executed, it is necessary that it has a class that implements the IZennoExternalCode interface
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.