C++ to C# conversion failed because of returning a structure pointer (AmiBroker) -


i working on amibroker c# plugin project. amibroker sdk written in c++ but, using c# plugin amibroker c++ c# plugin link in c# plugin works fine except 1 function written in c++ way:

pluginapi struct recentinfo* getrecentinfo(lpctstr ticker) {    //process & return recentinfo* (recentinfo structure) } 

in c# standard plugin has been converted way

public recentinfo getrecentinfo(string ticker) {     //process & return recentinfo } 

unfortunately, amibroker application crashes wrong conversion. did try convert way amibroker app working, failed multiple times have tried far:

attemp 1:

unsafe public recentinfo* getrecentinfo(string ticker) {     //process & return recentinfo* (recentinfo structure declared unsafe) } 

impact:

amibroker app not load

attemp 2:

public intptr getrecentinfo(string ticker) {     //process & return pointer using marshal.structuretoptr } 

impact:

amibroker app not load

attemp 3:

public void getrecentinfo(string ticker) {     //useless becoz no return type } 

impact:

amibroker loads & call function correctly how return structure pointer

so, scratching head find out exact conversion of c++ function in c#


Comments