I am not getting the answers back from my DLL calls. Here are the simple C# functions. Not sure why I am not getting the correct answers. I can DLL import kernel32d.dll and can call getTickCount() just fine. Just not my home grown DLL. Any insight would be appreciated.
Thanks,
Phil
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace wpa1
{
public class Class1
{
public string func1(string strIn)
{
System.Console.WriteLine(strIn);
char[] letters = { 'A', 'B', 'C' };
string alphabet = new string(letters);
return alphabet;
}
public float add(float a, float b)
{
return a+b;
}
}
}
Here is the Mathematica
code:
Needs["NETLink`"];
ReinstallNET["Force32Bit" -> True];
fullDllPath =
"c:\\users\\owner\\documents\\visual studio \
2015\\Projects\\wpa1\\wpa1\\bin\\Debug\\wpa1.dll";
LoadNETAssembly["wpa1.dll",
"c:\\users\\owner\\documents\\visual studio \
2015\\Projects\\wpa1\\wpa1\\bin\\Debug"];
add1 = DefineDLLFunction["add", fullDllPath,
"float", {"float", "float"}];
func1 = DefineDLLFunction["func1", fullDllPath,
"float", {"float", "float"}];
obj = NETNew["wpa1.Class1"];
NETObjectQ[obj]
stback = obj.func1 ("hi there")
OwnValues[stback]
a = obj.add ({1.2, 2.1})
Here is the output in Mathematica:
True
"hi there" (NETLink`Objects`NETObject$192170795466753).Function[Null,
If[NETLink`DLL`Private`checkArgCount["func1", {##1}, 2],
Wolfram`NETLink`DynamicDLLNamespace`DLLWrapper2`func1[##1], \
$Failed], {HoldAll}]
{HoldPattern[stback] :>
"hi there" (NETLink`Objects`NETObject$192170795466753).Function[
Null, If[NETLink`DLL`Private`checkArgCount["func1", {##1}, 2],
Wolfram`NETLink`DynamicDLLNamespace`DLLWrapper2`func1[##1], \
$Failed], {HoldAll}]}
{1.2 (NETLink`Objects`NETObject$192170795466753).add,
2.1 (NETLink`Objects`NETObject$192170795466753).add}