Так где же файл DLL нужно скопировать или указать ссылку, чтобы это работало?
- Я скопировал .dll и другие файлы в папку Debug (где текущий проект пытается ссылаться на DLL (Я упомянул это видео, и оно работает для консоли C#)
- Даже попробовал добавить ссылку на файл DLL - выдает ошибку, невозможно. добавить файл
- Добавление проекта C++ DLL в то же решение и ссылка на него дает System.DllNotFoundException
- Создан общий кроссплатформенный C++ ( Я думаю, что это входит в проект библиотеки NDK, но по-прежнему возникает та же проблема - DllNotFoundException.
- C++
Код: Выделить всё
#include "stdafx.h" extern "C"{ __declspec(dllexport) int add(int a, int b) { return a + b; } __declspec(dllexport) int subtract(int a, int b) { return a - b; } } - App.xaml.cs или любой другой стандартный общий проект .Net
Код: Выделить всё
public partial class App : Application { [DllImport("Dll1.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int subtract(int a, int b); [DllImport("Dll1.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int add(int a, int b); [DllImport("XamCppDll.Shared.so")] public static extern int cpp_GetValue(int a, int b); public App() { InitializeComponent(); int x = 100; int y = 15; int z = 0; int z1 = 0; try { cpp_GetValue(5, 6);//XamCppDll.Shared.so z = subtract(x, y);//Dll1.dll z1 = add(x, y);//Dll1.dll } catch (System.Exception ex1) { Debug.WriteLine(ex1.Message); } Debug.WriteLine(" {0} - {1} = {2}", x, y, z); Debug.WriteLine(" {0} + {1} = {2}", x, y, z1); MainPage = new MainPage(); }

< h3>Упомянутые руководства/коды
https://blog.xamarin.com/build-and-debu ... -apps-with -visual-studio-2015/
https://blogs.msdn.microsoft.com/vcblog ... id-native- приложения/
Подробнее здесь: https://stackoverflow.com/questions/521 ... dexception