Featured post
subscribing to c# CompositeCommand from c++ -
in c# assembly i've got global prism compositecommand subscribe this:
private static readonly compositecommand __mycommand = new compositecommand(); public static compositecommand mycommand { { return _mycommand; } }
from c# can subscribe command using:
[...].mycommand.registercommand(new delegatecommand<myclass>((c) => c.something()));
my problem: need subscribe command managed c++, , got no idea how function signature needs to used in delegatecommand. of time errors like:
error c2664: 'microsoft::practices::prism::commands::delegatecommand::delegatecommand(system::action ^)': conversion of parameter 1 'void (__clrcall *)(mynamespace::myclass ^)' in 'system::action ^' not possible.
how subscribe c# command? or there other way listen event (i can replace compositecommand different).
thanks!
i'm going assume you're using managed c++ - else, , there's bigger issues worry about.
it looks you're getting linking errors c# type. such, don't think issue related problems prism. in order c++ managed compiler link c# assembly, need produce c# assembly xml documentation file (see build tab in properties). enabled in project?
i used following simple proof of concept, testobject defined in c# assembly referenced c++ dll. compiled without issues.
header file:
void __clrcall commandcallback(project::infrastructure::testobject^ param); public ref class managedmodule : imodule { public: managedmodule(); virtual void __clrcall initialize(); private: };
implementation:
manageddll::managedmodule::managedmodule() { } void __clrcall manageddll::managedmodule::initialize() { action<project::infrastructure::testobject^>^ newaction = gcnew action<project::infrastructure::testobject^>(&commandcallback); delegatecommand<project::infrastructure::testobject^>^ newcommand = gcnew delegatecommand<project::infrastructure::testobject^>(newaction); project::infrastructure::commands::applicationexitcommand->registercommand(newcommand); return; } void __clrcall commandcallback(project::infrastructure::testobject^ param) { return; }
- Get link
- X
- Other Apps
Comments
Post a Comment