We have a big C++ project that's compiled as native unmanaged code. We need to use a feature from managed code, but we don't want to compile the whole project in /clr.
So I made a DLL, have a ref class named B, which is exposed in exported native class A. Problem is I get a C1190: managed targeted code requires a '/clr' option because of the vcclr.h include.
I'd like to know if there is a way to create some kind of interface that will have managed code within unmanaged methods.
Here's my code:
#pragma once
#include "EX_Port.h"
#include <vcclr.h>
ref class B;
class EX_API A
{
public:
A();
int DeviceCount();
private:
gcroot<B^> _device;
};
I managed to make it work by gcnew the B class within the cpp. But then I have a local object while I'd like to have it in the global scope. I just began doing CLI programming so I might not be aware of some practices.
Thanks