using dotnet with visual studio 2015 (and net framework 4.6.1 but its the same with others).
1) In visual studio 2015, created a library project (in this case a C#)
2) Double click in the project -> build events -> post build
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\gacutil.exe" /i "$(TargetPath)"
When the project its compiled, it adds to the GAC automatically. Please changes the bin folder according your installation.
3) in tools -> External tools, add the next external tool
Title: Get Qualified Assembly Name
Command: Powershell.exe
Arguments: -command "[System.Reflection.AssemblyName]::GetAssemblyName(\"$(TargetPath)\").FullName"
User Output Windows : checks
4) run tools -> Get qualified Assembly Name and checks the output windows
5) Creates the next class (Class1 may be its already creates)
namespace ClassLibrary2 // <-- changes it.
{
public class Class1
{
public string Ping(string t1,string t2)
{
return "pong "+t1+t2;
}
}
}
6) in php
$full="ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=746927f9726d7222"; // its from the output windows
$class = 'ClassLibrary2.Class1'; // its the namespace and the class.
$stack = new DOTNET($full,$class);
$r1="hello";
$r2="world";
echo $stack->Ping($r1,$r2);
IMPORTANT NOTE: PHP "caches" the dll library, so every time that the dll library is compiled, the php service should be restarted (restart the apache service).
IMPORTANT NOTE 2: May be you should run Visual Studio as an Administrator.