My C++ class has only one method:
string MyThreadsCpp::MyThreadsCppClass::train(){
double sum = 0.0;
long max = 100 * 1000;
int perc = 0;;
for (long n = 0; n < max; n++){
sum += 4.0*pow(-1.0, n) / (2 * n + 1.0);
int rem = n % (max/10);
if (rem == 0){
perc = 100 * n / max;
cout << perc << "%" << endl;
}
}
cout << "100%" << endl;
ostringstream oss;
oss << "Result = " << sum;
return oss.str();
}
It works fine.
C++/CLI class Library for this also has only one method:
string ThreadsCppWrapper::ThreadsCppWrapperClass::mytrainOp(int% i){
i++;
return ptr->train();
}
It builds fine.
C# code consuming this DLL:
namespace ThreadsCsharp
{
public partial class FrmMain : Form
{
private void btnTrain_Click(object sender, EventArgs e)
{
ThreadsCppWrapperClass obj = new ThreadsCppWrapperClass();
int i = 5;
obj.mytrainOp(i); /* This is where I get Error */
}
}
}
Intellisense Errors for the above line:
Error 1
No overload for method 'mytrainOp' takes 1 arguments
Error 2
Pointers and fixed size buffers may only be used in an unsafe context
Experts, Please help.