Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The "Run" looks to be a non-static class method. Although, it's possible to call such methods from C# this is not the primary use-case. It would be way easier to consume it from .NET if you expose it via COM, or at-least as a plain C interface:</p> <pre> <code> extern "C" __declspec(dllexport) void* Testing_Test_Create(); extern "C" __declspec(dllexport) void Testing_Test_Destroy(void* self); extern "C" __declspec(dllexport) int Testing_Test_Run(void* self, char* filePath, bool bEntry, double duration); </code> </pre> <p>And here is a sample how to call C++ class methods from C#:</p> <pre> <code> // Test.cpp in NativeLib.dll namespace Testing { class __declspec(dllexport) Test { public: explicit Test(int data) : data(data) { } int Run(char const * path) { return this-&gt;data + strlen(path); } private: int data; }; } </code> </pre> <pre> <code> // Program.cs in CSharpClient.exe class Program { [DllImport( "NativeLib.dll", EntryPoint = "??0Test@Testing@@QAE@H@Z", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Ansi)] public static extern void TestingTestCtor(IntPtr self, int data); [DllImport( "NativeLib.dll", EntryPoint = "?Run@Test@Testing@@QAEHPBD@Z", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Ansi)] public static extern int TestingTestRun(IntPtr self, string path); static void Main(string[] args) { var test = Marshal.AllocCoTaskMem(4); TestingTestCtor(test, 10); var result = TestingTestRun(test, "path"); Console.WriteLine(result); Marshal.FreeCoTaskMem(test); } } </code> </pre> <p>Entry point names might be different for your build configuration/compiler, so use dumpbin utility to obtain them. Again, this is just a proof of concept, in real code it would be better to use COM.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload