First, let me say I do know there exist 1000 of this question on google. I just haven't found one that helped me.
Basically my program has 3 layers: 1) VB.net DLL --> 2) C++ / CLR uses the managed part to allow it to be used by the next --> 2) unmanaged C++
I get an error in my console test app... So here's the code
VB.net:
C++/CLRCode:Public Class Add public function Adding(Byval x as Double, Byval y as Double) as Integer return x+y end function end class
header AddingWrapper.h
CPP --> AddingWrapper.cppCode:#include "stdafx.h" #include <msclr\auto_gcroot.h> #using "Class1.dll" class AddingWrapperPrivate; class __declspec(dllexport) AddingWrapper { private: AddingWrapperPrivate* _private; public: AddingWrapper(); int Adding(double* x, double* y); ~AddingWrapper(); };
Finally, where the error occurs:Code:#include "stdafx.h" #include "AddingWrapper.h" #using "Class1.dll" #include <msclr\auto_gcroot.h> using namespace System::Runtime::InteropServices; class AddingWrapperPrivate { public: msclr::auto_gcroot<Add^> add; }; AddingWrapper::AddingWrapper() { _private = new AddingWrapperPrivate(); _private->add = gcnew Add(); }; int AddingWrapper:: Adding(double* x, double* y) { return _private->add->Adding(*x, *y); }; AddingWrapper::~AddingWrapper() { delete _private; };
Test.cpp console app
Any insight on how I could fix this thing? I'm about to throw it out the windowCode:#include "stdafx.h" #include "AddingWrapper.h" #include <iostream> int main() { double x = 3; double y = 3; AddingWrapper* add; *add->Adding(x, y); //pointer to incomplete class type is not allowed std::cout << "here is the result"; return 0; }




Reply With Quote
