VC2005 Mixing Native & Managed: error C3767: 'member::function': candidate function(s) not
We are using VC2005, we have checked all the projects involved to ensure they are using the same /clr setting for compiling.The projects involved are usercontrol1 project, usercontrol2 project which used/depends on usercontrol1 project.usercontrol1 project defines an public Managed class, whcih 'wraps' a pointer to a native class, more or less like this:public ref class ManagedWrapper {NativeClass* NativeObject;public:ManagedWrapper() { NativeObject = new NativeClass(); } ~ManagedWrapper() { delete NativeObject; }NativeClass GetterFunction(void) { return *NativeObject; }void SetterFunction( NativeClass* NewObject) { *NativeObject = *NewObject );}This class compiles fine in usercontrol1 project, then we add an using usercontrol1 to usercontrol2and attempt to use the control in usercontrol1 in usercontrol2, this is when it gives use errors duringthe compile:.\usercontrol2.cpp(xx) : error C3767: 'ManagedWrapper::GetterFunction': candidate function(s) not accessible.\usercontrol2.cpp(xx) : error C3767: 'ManagedWrapper::SetterFunction': candidate function(s) not accessible It would be nice to beable to use the ManagedWrapper everywhere we want to use the NativeClass, as using the NativeClass alot in Managed UIs, Controls, etc... requires alot of pointer management that is prone to error. If we could hide the pointermanaging in ManagedWrapper and use ManagedWrapper instead that would be wonderful. Is this just a limitation that we are going tohave to live with, or is there another way to approach our problem, that we just haven't though of yet?Thanks,
The point of having a wrapper is to expose a managed object, which is countermanded by having the GetterFunction and SetterFunction methods whose signatures involve unmanaged objects. It seems to me that your higher-level goal is to have the ability to assign the state of one object to another. If this is the case, remove these methods and instead implement an overloaded assignment operator (operator=) that takes a handle to ManagedWrapper as an argument.
In general, your C++/CLI wrapper ought to act as a bridge to the "inner" unmanaged objects by implementing public methods to wrap each of the corresponding "inner" methods.
Brian