Search code examples
c#c++visual-studioc++-cliclr

Adding includes in my CLR project gives WLR cannot be compiled with /clr enabled


// This is the main DLL file.

#include "stdafx.h"

#include "Tga2DCLI.h"
//#include <Game.h>
#include <Windows.h>
Tga2DCLI::Tga2DGame::Tga2DGame()
{
    //myGame = new CGame();
}

void Tga2DCLI::Tga2DGame::Init(System::String ^ aVersion, System::IntPtr aHWND)
{
    HWND convertedHWND = reinterpret_cast<HWND>(aHWND.ToInt64());
    //myGame->Init(L"", convertedHWND);
}

When #include <Game.h> is not commented out it cause the error C1189 #error: WRL cannot be compiled with /clr option enabled

I'm trying to create a windows form (C#) that shows an game engine running in a picturebox the game engine is in C++, the code snippit is from my c++/clr project in the solution.

my issue is I don't really understand the WRL error? So I do not understand how to get it running. And I need the Game include to init the engine to get it running in the windows form.


Solution

  • The Windows Runtime C++ Template Library (WRL) is simply not compatible with C++/CLI.

    Compiling using WRL requires the /ZW option. And this language extension is simply incompatible with the /CLR that is required to use .NET.

    WRL is in nearer to COM than to .NET.