calling managed function from unmanged class
-
Have been trying without success to call an managed function from within an unmanaged class. This would seem to be a basic requirement, of the dotnet so I am obviously doing something wrong. Given the class CMyManaged header as: #pragma once public __gc class CMyManaged { public: CMyManaged(void); ~CMyManaged(void); void MyFun(void); }; and a standard MFC dialog class, I wish to call MyFun() from within MyMFCDlg(). Now I went about this by declaring a CMyManaged variable m_MyManaged; in the unmanaged MyMFCDlg() header file. Then in MyMFCDlg.OnInitDialog() I try to call m_MyManaged.MyFun(); Have tried declaring the managed variable as gcroot m_MyManaged; But various means to call MyFun() have all resulted in compilation errors. Any help would be appreciated, as the C# dialog box is to limited I need to continue developing partially in Unmanaged C++. Many thanks
-
Have been trying without success to call an managed function from within an unmanaged class. This would seem to be a basic requirement, of the dotnet so I am obviously doing something wrong. Given the class CMyManaged header as: #pragma once public __gc class CMyManaged { public: CMyManaged(void); ~CMyManaged(void); void MyFun(void); }; and a standard MFC dialog class, I wish to call MyFun() from within MyMFCDlg(). Now I went about this by declaring a CMyManaged variable m_MyManaged; in the unmanaged MyMFCDlg() header file. Then in MyMFCDlg.OnInitDialog() I try to call m_MyManaged.MyFun(); Have tried declaring the managed variable as gcroot m_MyManaged; But various means to call MyFun() have all resulted in compilation errors. Any help would be appreciated, as the C# dialog box is to limited I need to continue developing partially in Unmanaged C++. Many thanks
3green wrote: have all resulted in compilation errors. Post the compiler error messages, otherwise we have to guess. Obvious things to check: Do you have properly configured "mixed mode" project settings? Do you have required #include and import statements? If you don't know what one or both of those are you need to use MSDN to read about "mixed mode" development.
"No matter where you go, there your are." - Buckaroo Banzai
-pete