I wish to call C++ function (here Score()) which is present in Score_Update1.dll. Both C# & C++ files get compiled successfully. I have also put above dll into the Debug/bin of C# project. But when I run C# code it gives EntryPointNotFoundException. What could be the reason behind this Exception? I tried dependency walker for Score_Update1.dll. But it doesn't show any Entry Point
I wish to use PInvoke technique for calling C++ function from C#
// Score_Update1.h #pragma once #include <iostream> using namespace std; using namespace System; extern "C"{ #define MYAPI __declspec(dllexport) namespace Score_Update1 { public class MYAPI UpdateScore { // TODO: Add your methods for this class here. public: void Score(); }; } } // This is the main Score_Updat1.dll DLL file. #include "stdafx.h" #include "Score_Update1.h" using namespace Score_Update1; void UpdateScore::Score() { cout<<"Score has been updated"; } C# code is as follows:
using Score_Update1; using System.Runtime.InteropServices; namespace GameTesting { class Game { [DllImport("Score_Update1.dll")] internal extern static void Score(); static void Main(string[] args) { try { Game.Score(); } catch (Exception ex) { Console.WriteLine(ex); } } } }
__thiscall