How to call a c++ function that returns a class from c# -
i have functions written in c++ , want use functions in c# project. worked couple of functions in functions in returned class, doesent seem work (i have same class in both sides). created adapter returns class called cprofile :
class cprofile { public double timestamp; public int diml, dimr; }; extern "c" __declspec(dllexport) cprofile getprofileadapter(int nint) { std::cout << "get profile" << std::endl; profile profile=r->getprofile(nint); cprofile cprofile; std::cout << "get time stamp" << std::endl; cprofile.timestamp=profile.timestamp; std::cout << "get diml" << std::endl; cprofile.diml=profile.leftprofile.size(); std::cout << "get dimr" << std::endl; cprofile.dimr=profile.rightprofile.size(); return cprofile; }
and in c# project call function :
class cprofile { public double timestamp; public int diml, dimr; }; static void main(string[] args) { cprofile c = new cprofile(); c = getprofileadapter(0); } [dllimport("c:\\ran\\pmcppdllran.dll")] static extern cprofile getprofileadapter(int nint);
Comments
Post a Comment