Using Visual Studio 2013, I am currently trying to generate a .dll with C++ Code, which i want to include into a VB.NET project. To create the .dll i tried to follow these tutorials:
- http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c9855/DLL-Tutorial-For-Beginners.htm
- http://msdn.microsoft.com/de-de/library/ms235636.aspx
For now my .dll Project contains only the following files:
- External Dependencies (auto generated by VS2013)
- Header Files: stdafx.h, targetver.h (auto generated)
- dllmain.cpp with default entry point Method DllMain and stdafx.cpp (auto generated)
- MyDLL.cpp and containing the implementation of my methods which should be exported (for now one void method without parameters)
- Headerfile MyDLL.h
- Source.def (i only added the .def file after i tried using the __declspec(dllexport) statement)
MyDll.h contains:
#ifndef _DLL_MYDLL_H_
#define _DLL_MYDLL_H_
#include <iostream>
#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif
extern "C"
{
DECLDIR void MyMethod();
}
#endif
MyDLL.cpp contains:
#include "stdafx.h"
#include "MyDLL.h"
#define DLL_EXPORT
extern "C"
{
void MyMethod(){
//my code
}
When i create the .dll (by using "build > build solution" in VS2013) it compiles without errors and warnings. However, when i try to set a reference in my VB-Project by using "project > add reference" and selecting the .dll that was created in the DEBUG-Folder of my DLL-Project, i get an error stating that the reference could not be added and that i should make sure that the file is accessible and that it is a valid assembly or COM component.
Am i missing some vital settings in my dll/vb project here? Thanks in advance for your advice.