I am trying to abstract out a c++/clr interop. I have a nativeConsole app (will end up being a MFC app), the abstracted InteropToCSharp library and a WinFromControlLib. You can see the intended configuration here
The problem I am having is:
- Once I introduce "#Using WinFormControlLib.dll" into InteropToCSharp::Interop it requires the InteropToCSharp and nativeConsole applications are set to clr. However, after I clear the errors associated with setting the projects to clr visual studio skips all break points.
Inorder to get WinformControlLib.dll in InteropToCSharp I took the following steps:
#using "WinFormControl.dll was inserted into InteropToCSharp.h This required moving to CLR in InteropToCSharp:
- Common Language Runtime support and Debug Information Format was changed from “Zl” to “Zi”
This also required moving to CLR in nativeConsole:
- Common Language Runtime support and Debug Information Format was changed from “Zl” to “Zi”
- Enable C++ Exceptions changed from Yes (/EHsc) to Yes with SEH Exceptions (/EHa) because of "‘/clr’ and ‘/EHs’ command-line options are incompatible"
- Because of the error "‘/clr’ and ‘/RTC1’ command-line options are incompatible" the previous state: Basic runtime Checks “Both (/RTC1, equiv. To /RTCsu) (/RTC1) was changed to: “Default”
I have tried with and without “Use Managed Compatibility Mode” Selected.
The file structure can be seen here
// Project: nativeConsole
// File: nativeConsole.cpp
#include <iostream>
#include "InteropToCSharp.h"
int main()
{
Interop interop = Interop();
std::cout << interop.GetVal() << " Hello World!\n" << std::endl;
}
// Project: InteropToCSharp
// File: InteropToCSharp.h
#pragma once
#ifndef WRAPPER_H
#define WRAPPER_H
#using "WinFormControlLib.dll" //Adding this requires clr however after clearing
//errors all debug points are skipped.
class __declspec(dllexport) Interop
{
public:
Interop() {}
~Interop() {}
int GetVal()
{
return 1234;
}
};
#endif
//Project: WinFormControlLib
//File: SomeModel.cs
namespace WinFormControlLib.Model
{
public class SomeModel
{
public SomeModel() { }
public static int GetSomeValue() { return 987; }
}
}