H
Humble_Aspirant
Guest
I had mostly worked on unmanaged code, recently for my work I have to use CLI/C++ projects. Some of the files are unmanaged code, so while including I use #pragma managed(push, off) I had seen in full unmanaged codes we have been using event and deligate in Ref classes.
event someHandler^ someEvent;
public delegate void someHandler(ManagedCpp::sharedPtr<std::string> ^);
But now I need to create the same kind of mechanism for a mixture of managed and unmanaged. So as I was making that Model view class as managed, I am unable to include it in unmanaged Class.
Managed class where I will be defiing the event(s) and delegate...
public delegate void someHandler(ManagedCpp::sharedPtr<std::string> ^);
class ModelView{
managedCpp::sharedPtr ^ memberPtr
public:
event someHandler^ someEvent;
ModelView(){
memberPtr= gcnew managedCpp::sharedPtr<std::string>
}
//some other functions
// a getter() to get the memberPtr
// a setter() to set the value of memberPtr
}
So I need to include this class in others classes of which some are managed and others are unmanaged.
When I include in managed class it throws error.
error C3821: 'memberPtr': managed type or function cannot be used in an unmanaged function
Could anyone please help me how I can resolve this encountered issue?
Continue reading...
event someHandler^ someEvent;
public delegate void someHandler(ManagedCpp::sharedPtr<std::string> ^);
But now I need to create the same kind of mechanism for a mixture of managed and unmanaged. So as I was making that Model view class as managed, I am unable to include it in unmanaged Class.
Managed class where I will be defiing the event(s) and delegate...
public delegate void someHandler(ManagedCpp::sharedPtr<std::string> ^);
class ModelView{
managedCpp::sharedPtr ^ memberPtr
public:
event someHandler^ someEvent;
ModelView(){
memberPtr= gcnew managedCpp::sharedPtr<std::string>
}
//some other functions
// a getter() to get the memberPtr
// a setter() to set the value of memberPtr
}
So I need to include this class in others classes of which some are managed and others are unmanaged.
When I include in managed class it throws error.
error C3821: 'memberPtr': managed type or function cannot be used in an unmanaged function
Could anyone please help me how I can resolve this encountered issue?
Continue reading...