c++ - Windows Phone 8.1: C# Callback with IList variable fails to cast to IVector -
i have c# windows phone 8.1 visual studio (2013) project declares interface callback
public interface icallback { /// <summary> /// child callback must override method , fired when time comes /// </summary> /// <param name="files">the resultant files </param> /// <param name="code">error code</param> void gotfilelist(filetype type, ilist<fileinfo> files, errorcode code); }
i have c++/cx wrapper implements follows:
ref class callbackimpl sealed : icallback { private: callbackimpl(){} public: virtual void gotfilelist(filetype type, windows::foundation::collections::ivector<object^>^ files, errorcode code); }
my problem on release build, when c# calls icallback::gotfilelist
_callback.gotfilelist(filetype, result ilist<fileinfo>, errorcode.ec_no_error);
it throws exception system.invalidcastexception: specified cast not valid
. exception refers casting ilist ivector.
debug fine; meaning, can add values internal ilist , call icallback::gotfilelist , ilist values in c++ ivector without problems.
i compared release/debug project properties (in projects: c# core lib, c++/cx wrapper , c++/cx application) , did not find difference can explain exception on release build only.
any ideas?
i found simple answer. since ilist of proprietary data type fileinfo
fails cast ivector. changed interface function signature ilist<object>
instead of ilist<fileinfo>
(and ivector respectively in c++ wrapper), works.
here new code snippet:
public interface icallback { /// <summary> /// child callback must override method , fired when time comes /// </summary> /// <param name="files">the resultant files </param> /// <param name="code">error code</param> void gotfilelist(filetype type, ilist<object> files, errorcode code); }
c++ wrapper:
ref class callbackimpl sealed : icallback { private: callbackimpl(){} public: virtual void gotfilelist(filetype type, windows::foundation::collections::ivector<object^>^ files, errorcode code); }
Comments
Post a Comment