Create a New C# Add-on in Visual Studio

You can create C# add-ons for Tacview using Visual Studioarrow-up-right. In this tutorial we are using Visual Studio Community 2022.

Download and run the latest version of Tacviewarrow-up-right.

In Visual Studio, create a new Class Library (.NET framework) project:

Create a new DLL Project

Enter your project name, solution name, and location. Make sure you are targeting .NET Framework 4.7.2.

Project name and location

Click Create. A blank project will be created for you.

Project created

From C:\Program Files (x86)\Tacview\SDK\cs\, copy the folder Tacview.Wrapper into the folder of your new add-on:

Copy wrapper

Right-click on the solution to Add -> Existing Project. Find the Tacview.Wrapper in your add-on folder and add the project at project -> Windows -> Tacview.Wrapper.vcxproj

Add wrapper

Right-click on your project and add a reference to the wrapper.

Add reference to wrapper

Make sure everything is configured to build as 64-bit target x64. Do not build for Any CPU.

The following is an example of a build configuration that should work if debugging in x64.

Configure x64

Copy the source code of the class DLL Interface from C:\Program Files (x86)\Tacview\SDK\cs\HelloWorld\HelloWorld.DllInterface.cs to your add-on.

Copy Hello World

Obtain the most recent version of DllExport.bat from this GitHub repositoryarrow-up-right and place it in your add-on folder.

Copy DLL Export

Close the solution, then run DllExport.bat in your add-on folder

You will be prompted to browse to the location of the solution of your add-on.

Run DLL Export

Make sure x64 is selected, tick the Installed checkbox next to your Add-on and Apply.

Apply DLL Export

Reload your project.

Right-click on your Project and select Properties to set the Output Path equal to C:\ProgramData\Tacview\AddOns\YourAddOn\, so that Tacview can automatically find and load your DLL:

Set Output Path

To debug your add-on, specify Tacview as the external program to start:

Set External Program

Troubleshooting

Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019

In the case that this error message appears in the Tacview Debug Log:

Make sure that you are not attempting to run a Debug version of this addon if you are not a developer. Debug builds require additional DLLs and tools.

First, use the link providedarrow-up-right to download the latest version of Microsoft Visual C++ Redistributable for Visual Studio, even if you are sure that you have already downloaded everything your need. Close and re-launch Tacview.

If the error is still occurring it could be caused by the DLL having been compiled in Debug mode and now being run on a computer that is not set up for debugging. If you are the developer, be sure you are compiling the DLL in Release mode. If you are not the developer, please contact the developer.

When I debug or throw exceptions in a .NET add-on, Tacview crashes.

Make sure you are running at least Tacview 1.9.3, in which this issue is resolved. This issue occurs only on newer systems because it has to do with a security enhancement introduced in latest versions of Windows in combination with latest Intel and AMD processors.

Last updated