This is not a duplicate of "how to call C++ function from C#"
I know how to do it for regular PC app and I tried and it works:
This is called P/Invoke
1.
Create a C++ dll project,
but you can't add the C++ dll project as a reference to the C# project.
Copy the dll from C++, and paste the dll to the C# exe folder
2.
in C# use [DllImport...]
in C++ use extern "C" __declspec(dllexport) ...
But when I do this on WindowsPhone, failed.
There are 2 type of unmanaged c++ native dll project for windows phone, I tried both
DLL (Windows Phone) <- WRT DLL 8.1
DLL (Windows Phone Silverlight 8.1)
I don't know where to place the dll file. Because the finally exe is a package. I can't place the dll in the same folder with the package. The dll should be in the package, as a part of the package.
So I tried to add the dll as a resorce file in the C# WP8.1 SL project.
But the function call failed.
So what I want to know is, how to place the dll, how to hook up the dll with the WP8.1 SL project?
Is there any one try that before?
Thank you guys for the answer.
//------------------------------------------------------------
So the correct way is For a [C# WP8.1 SL] project, I need to
create a [C++ Runtime Component DLL] <- as bridge
create a [C++ Native WP SL DLL] <- real dll
Add the [C++ Runtime Component DLL] as a reference to [C# WP8.1 SL]
And the [C++ Native WP SL DLL] as a reference to [C++ Runtime Component DLL]