I have a Visual Studio Solution with a Class Library (C#) and a CLR Class Library (C++). The CLR class library builds properly and it as simple as, for the header file:
public ref class CLRClass
{
public:
static void CLRMethod();
};
The cpp implements just an empty CLRMethod. In the C# library I added a reference to the CLR project and I am just calling the CLR method:
CLRClass.CLRMethod();
The C# library does not build, returns error:
error CS0103: The name 'CLRClass' does not exist in the current context
But surprisingly if I F12 on the CLRClass in Visual Studio it does bring me to the correct metadata of the compile file in the dll, showing that the CLR library is correctly compiled and accessible:
public class CLRClass
{
public CLRClass();
public static void CLRMethod();
}
I don't understand how the metadata is accessible but when compiling the C# library I get the CR0103 error, any suggestions on how to fix this?
It's a problem of C# .Net Target Framework Version. Notice that you have this warning in your reference:
This is because the C# Class Library targets a Framework version that is older (4.7.1) than the one that the C++/CLI framework (4.8). Just retarget your C++ library.