I'm attempting to use the C++ REST SDK. I'm using this example as my starting point.
What has worked so far is creating a new Windows CLR application in VS2015, adding a new cpp file, installing cpprestsdk thru NuGet, pasting the tutorial code into the cpp, turning off management for that cpp file, and compiling. Works as expected.
What also works is creating a new Windows CLR application and making a blank form by adding a cpp file with:
#include "MainForm.h"
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^ args) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
MyProject::MainForm form;
Application::Run(%form);
}
And adding a new UI Windows Form element "Main Form" and keeping the code managed. This compiles fine and displays a blank window which I can close.
The issue lies when I add a new .cpp file into the above and paste the example into it as I've done before. I set this new .cpp file as unmanaged and rename the function something arbitrary. I'm not calling this function in any way. It compiles fine, however when I try to launch the program, I have AccessViolationExceptions.
I've done plenty of looking into running mixed managed code and I don't see what error I'm making.
EDIT: For now, I've circumvented the problem by avoiding Windows Forms and using Qt GUI instead.