I am trying to call native C++ code from C# project. To do that I followed the steps from this post.
But I get a stackoverflow exception when I create a huge array in the C++ file. Here is the code:
//CSharpTest.h
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpTest
{
class Program
{
static void Main(string[] args)
{
CpTest.Class1 instance = new CpTest.Class1();
Console.WriteLine(instance.DoSomething());
Console.ReadKey();
}
}
}
And the c++ file
// CpTest.h
#pragma once
using namespace System;
namespace CpTest {
public ref class Class1
{
public:
int DoSomething(){
int arr[640 * 480];
return 123;
}
// TODO: Add your methods for this class here.
};
}
The array declaration is causing the stackoverflow exception.
Earlier when I was running only the native C++ code I increased the stack size by increasing the 'Stack Reserve Size' from the project properties.
But for this case I don't know what to do.