Reputation: 223
I need to call c# method in native c++. I followed this guide, download it, it's worked, but when I try it on new version of .net I cannot reproduce. The main idea of this code is call c# method in such way: C# .dll -> C++/CLI(managed c++) -> c++
C#
public static class ManagedClass
{
public static bool Check()
{
return true;
}
}
Managed c++
namespace ClassLibrary1 {
public ref class DoWork
{
public: bool CheckCSharp()
{
return CSharp::ManagedClass::Check();
}
};
}
__declspec(dllexport) bool Check()
{
ClassLibrary1::DoWork work;
return work.CheckCSharp();
}
c++
#include "ClassLibrary1.h"
_declspec(dllexport) bool Check();
int main()
{
std::cout << Check();
system("pause");
return 0;
}
It's show error
Error LNK2019 unresolved external symbol "bool __cdecl Check(void)" (?Check@@YA_NXZ) referenced in function _main
1 unresolved externals
Upvotes: 1
Views: 1416