Hi!
I have had some success building a .dll in ‘native’ C++ that exposes routines that call CUDA, and in using that .dll in a ‘native’ C++ test program (I am using Visual Studio 2008). But when I try to use this .dll in a .NET-enabled application, using either C++ with ‘common language runtime’ support or using C#, the code crashes inside the .dll, on a not-particularly conspicuous instruction, with the exception “An unhandled exception of type ‘System.AccessViolationException’ occurred in Example_Use_PInvoke.exe” (Example_Use_PInvoke.exe is the name of my test routine.) This is not a problem with data marshaling – the function I am calling has no arguments. I believe I have scrupulously used all the advice that Microsoft provides for calling unmanaged-code .dlls from managed code, and other routines I have written work OK.
Has anyone succeeded at this? I am very fond of C# as a development environment, and I thought I could just develop my class library in C++ and use it from C#, but so far, no luck.
// AllenC