I write a C# dll to use in C++. But it has some error:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
In my C# Dll project, i use another library call DllExport: DllExport. Here is my C++ code:
#include<stdio.h>
#include<iostream>
#include<Windows.h>
#include<string>
using namespace std;
int main() {
const char* exportDll = "C:\\Users\\source\\repos\\MacroLib\\MacroLib\\bin\\x64\\Release\\net6.0\\MacroLib.dll";
HMODULE hexportDll = LoadLibraryA(exportDll);
typedef int(__stdcall *AntiMacro)(string path);
typedef void(__cdecl* ScanMacro)(string path, bool isFolder);
typedef int(__cdecl* add)(int a, int b);
auto padd = (add)GetProcAddress(hexportDll, "_add");
int m = padd((int)5, (int)6);
cout << m << endl;
return 0;
}
Note that, when i put a breakpoint on this line: auto padd = (add)GetProcAddress(hexportDll, "_add");
I can see the exact address that I observe in CFF Explorer. Can anyone suggest some ways to fix it?