Hy

So I am fairly new to OpenCL and GPGPU in general , all has been great until I wanted to integrate it with one of my C# applications issue being that if I call the functioning from C# OpenCL does not find any valid devices but if I switch from .dll to .exe and execute it as a console application it works just fine

C++ code sample
Code :
#if _MSC_VER 
#define EXPORT_API __declspec(dllexport) functions with this
#else
#define EXPORT_API 
#endif
 
.........
 
extern "C"
{
int EXPORT_API CLGetDeviceCount()
{
	cl::Platform::get( &platforms);
	cl_context_properties cps[3] =  { CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[i])(), 0 };
	context = cl::Context (CL_DEVICE_TYPE_ALL , cps);
 
	devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
	return devices.size() ;
}
}

C# code sample
Code :
using System.Runtime.InteropServices;
 
......
 
public class SimpleCLCall 
 {
 [DllImport("CLTest")]
    private static extern int CLGetDeviceCount();
 
  public int clDeviceCount()
  {
  return CLGetDeviceCount();
  }
}