I know there are many other questions like this, but no one has helped me out. So I'm writing a dll for my mysql connection in c++ to use it later in C#. But it says to me that it can't find the entrypoint of my method.
Any ideas?
Here is my C++ code:
Sweepape.h
#ifdef SWEEPAPE_EXPORTS
#define SWEEPAPE_API __declspec(dllexport)
#else
#define SWEEPAPE_API __declspec(dllimport)
#endif
extern "C" {
//// Diese Klasse wird aus der DLL exportiert.
//class SWEEPAPE_API CSweepape {
//public:
// CSweepape(void);
// // TODO: Methoden hier hinzufügen.
//};
//
//extern SWEEPAPE_API int nSweepape;
//extern SWEEPAPE_API int nYear;
//
//SWEEPAPE_API int fnSweepape(void);
SWEEPAPE_API int connect2(int a);
}
Sweepape.cpp
#include "Sweepape.h"
SWEEPAPE_API int connect2(int a)
{
std::cout << "Connecting" << a;
return 0;
}
C#
using System;
using System.Runtime.InteropServices;
namespace ConsoleApp1
{
class Program
{
private const string path = @"C:\Users\chris\source\repos\Sweepape\Debug\Sweepape.dll";
[DllImport(path, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern int connect2(int a);
static void Main(string[] args)
{
connect2(2);
}
}
}