Donate

Categories

Write An ARMA Extension In C#/.NET

Hey, so like me you want the ability to do more with ARMA but C++ is not one of your favorite languages, here is a small tutorial on how to write a working ARMA DLL completely in C# (and other .NET languages I presume), no need for C++/CLR or ARMA2NET.

Once installed, start a new C# “Class Library” project.Next step is to download a NuGet Package called “Unmanaged Exports“. To do this goto the menu “Project -> Manage NuGet Packages”, once the dialog opens, search for “Unmanaged Exports”, install it and close the dialog.Now, the project is setup and you are ready to writing some code. Here is the most basic of examples (Download link below).

The class itself can be called anything, DllEntry seems appropriate. Once you compile the code, the RVExtension gets called whenever you execute a callExtension. In the SQF code below, the function string, is available via the function param in RVExtension. (I had a string encoding issue, i thought maybe marshaling would help…not sure…).

Before you can compile, the Unmanaged Exports requires the projects “Platform Target” to be set to either x86 or x64 (I suggest x86 if you are not sure). To do this right click on the project and select “Properties”, click the “Build” section and change the “Platform Target” dropdown.

Now compile the project and put the resulting DLL into an ARMA mod folder. (Eg. @armaExtCS). Thats it, to run it in ARMA just execute this:

I’m making scripts for Arma 3 in sqf, so I have a folder with a mission.sqm file. In the same folder, I had to copy the .dll file from the .cs project. So I have actually a mission.sqm file and my ARMAExtCS.dll file.

Now I started Arma 3 -> Editor -> load my mission and wrote the same code in my debug console, but it didn’t work.