Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to call C++ code from C# code.

I have written following code in C++
C++
extern "C" __declspec(dllexport) void myFunction()
{
  //Some code
};



Following code in C#
C#
[DllImport("D:/MyProject.dll")]
private static extern void myFunction();


When I run the code it gives Exception HRESULT: 0x8007007E.

Thanks in advance.
Posted
Updated 15-Apr-13 2:29am
v2

1 solution

See https://www.google.co.uk/search?q=0x8007007E[^]. Note also that your C definition says that the function returns an int, but your C# definition says void; it is better to match the two.
 
Share this answer
 
Comments
Shmuel Zang 15-Apr-13 4:54am    
5'ed.
Richard MacCutchan 15-Apr-13 5:04am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900