We have two C++/CLI projects, a pure CLR project and a mixed-mode project that exists to provide our unmanaged codebase access to the pure CLR project. We are having trouble getting the mixed-mode project to see symbols defined in the pure CLR project.
Specifically we have a form, call it MainForm, defined in the purely-managed project. It's a typical C++/CLI Windows Form:
MainForm.h:
public ref class MainForm : public System::Windows::Forms::Form
{
public:
MainForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
}
...
};
Our mixed-mode "wrapper" project tries to use it, like so:
ManagedDialogProvider.h:
namespace ManagedWrapper
{
public ref class ManagedDialogProvider
{
static void ShowDialog()
{
OurManagedComponents::MainForm^ form = gcnew OurManagedComponents::MainForm();
}
};
}
(We then have a C++/MFC class in the mixed-mode project, CManagedDialogProvider, that calls ManagedDialogProvider so that our unmanaged code can use it. The error isn't occurring there, however.)
When I try building the mixed-mode project, it tells me that MainForm is not a member of OurManagedComponents. (Error in ManagedWrapper::ManagedDialogProvider::ShowDialog().)
Notes:
- The mixed-mode project has a reference to the managed project.
- I have tried using an #include at the top of the managed wrapper class instead of a reference, and while this compiled, I then couldn't load the form due to its resources not being found. I backed out of this solution as it's not accepted practice if I understand correctly; .NET projects should reference each other via assembly references only.
- I've verified that the managed class is accessible (public).
- I've checked the Object Browser to ensure that OurManagedComponents is visible and contains MainForm.
Any ideas? The same mixed-mode project has no trouble wrapping C# managed components, but when I tried using that same approach for this C++/CLI managed component, these issues appeared.
OurManagedComponents::MainForm
you should probably post a reduced version of the class. – Daniel EarwickerCMainDialogProvider
. – ali_bahoo