我的C#/C+中缺少入口点+;互操作性
我在做我的程序,这是我的学士学位(C#/C++互操作性)所需要的,我的代码中缺少入口点,这是我的问题。。。我尝试创建简单的数字生成器,这将是C++类调用中的GigAARD数。起初我不知道如何通过一门课,但后来我在这一页上找到了方法。。。请帮我修一下 我添加了我的代码: [C++]我的C#/C+中缺少入口点+;互操作性,c#,c++,interop,entry-point,language-interoperability,C#,C++,Interop,Entry Point,Language Interoperability,我在做我的程序,这是我的学士学位(C#/C++互操作性)所需要的,我的代码中缺少入口点,这是我的问题。。。我尝试创建简单的数字生成器,这将是C++类调用中的GigAARD数。起初我不知道如何通过一门课,但后来我在这一页上找到了方法。。。请帮我修一下 我添加了我的代码: [C++] 非常感谢 那么,您应该使用dumpbin,找到您函数的损坏名称,然后添加EntryPoint=“yourMangledName”在DllImport属性中。您能在编译时或运行时发布完整错误吗?GeneratorShar
非常感谢 那么,您应该使用dumpbin,找到您函数的损坏名称,然后添加EntryPoint=“yourMangledName”在DllImport属性中。您能在编译时或运行时发布完整错误吗?GeneratorSharp.exe中出现“System.EntryPointNotFoundException”类型的未经处理的异常。其他信息:在DLL“DllTriedGenerator.DLL”中找不到名为“Vytvor\u Triedu”的入口点。是否有其他方法查找损坏的名称因为当我尝试打开dumpbin系统错误时,我安装了PE explorer,在那里打开我的dll,但它只显示入口点的地址,而不显示名称。。。我绝望了
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
__declspec(dllexport) class Generator
{
private:
int zaciatok;
int koniec;
int pocetprvkov;
int *pole;
public:
Generator(){}
void Vytvor (int zaciatok, int koniec, int pocetprvkov)
{
srand((unsigned)time(0));
pole= new int [pocetprvkov];
}
void Napln()
{
for(int a=0; a<pocetprvkov; a++)
{
pole[a] = rand() % (koniec - zaciatok +1) + zaciatok;
}
}
void Vypis()
{
for(int a=0; a<pocetprvkov; a++)
cout << pole[a] << endl;
}
~Generator()
{
delete[] pole;
pole= 0;
}
};
extern "C"
{
__declspec(dllexport) Generator* Vytvor_Triedu() { return new Generator(); }
__declspec(dllexport) void Vytvor(Generator* prva) {prva->Vytvor(5,25,4); }
__declspec(dllexport) void Napln(Generator* prva) {prva->Napln(); }
__declspec(dllexport) void Vypis(Generator* prva) {prva->Vypis(); }
__declspec(dllexport) void Vymaz(Generator* prva) { delete prva; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace GeneratorCsharp
{
class Program
{
[DllImport("DllTriedaGenerator.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Vytvor_Triedu();
[DllImport("DllTriedaGenerator.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void Vytvor(IntPtr value);
[DllImport("DllTriedaGenerator.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void Napln(IntPtr value);
[DllImport("DllTriedaGenerator.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void Vypis(IntPtr value);
[DllImport("DllTriedaGenerator.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void Vymaz(IntPtr value);
static void Main(string[] args)
{
IntPtr trieda = Vytvor_Triedu();
Vytvor(trieda);
Napln(trieda);
Vypis(trieda);
Vymaz(trieda);
}
};
}