System.EntryPointNotFoundException вызывает DLL Visual C++ из VB.NETC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 System.EntryPointNotFoundException вызывает DLL Visual C++ из VB.NET

Сообщение Anonymous »

В учебных целях я создал свою первую очень простую dll Visual C++, чтобы использовать ее в VB.Net.

Код: Выделить всё

//pch.h

#ifndef PCH_H
#define PCH_H
#include "framework.h"
//#include "Code.h"
#endif //PCH_H

Код: Выделить всё

//code.h
#pragma once
#include "pch.h"
#include 
using namespace std;

#ifndef ADD_CODE_H
#define ADD_CODE_H
//extern "C"  //debugger says that IS NOT compatible with the __stdcall declaration
//{
__declspec(dllexport) string __stdcall add_code(string text); //same if I remove   __stdcall
//}
#endif

Код: Выделить всё

//code.cpp
#include 
#include 
#include "pch.h"
#include "Code.h"

using namespace std;

string __stdcall add_code(string text) {         //same if I remove __stdcall

return text;
}

Код: Выделить всё

// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include "Code.h"

BOOL APIENTRY DllMain( HMODULE hModule,
DWORD  ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
Ошибок при компиляции кода Visual C++ нет. Пробовал как x86, так и x64.
Из VB.NET я пытаюсь вызвать dll с помощью этого кода:

Код: Выделить всё

Imports System.Runtime.InteropServices

 '' //same if I remove stdcall Convention
Private Shared Function add_code(ByVal text As String) As String
End Function

Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Dim foo As String = add_code("ppp")

End Sub
Пробовал как x86 (dll x86), x64 (dll x64), так и любой процессор (dll x86 или x64).
Я получаю сообщение об ошибке: System.EntryPointNotFoundException: не удалось найти точку входа с именем «add_code» в DLL.

Подробнее здесь: https://stackoverflow.com/questions/797 ... rom-vb-net
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»