I am building a C#  (WCF) application and it uses a dll  Since I am working with CUDA programming., I have written a small program in CUDA C++ which returns a string and generated Dll of it. String Contains Information about Nvidia GPU card (mostly one page Information) . 

.I am using PInvoke - (Dllexport and DllImport). C# application is importing this Dll . After running the application I am getting the following exception

-> System.AccessViolationException : Attempting to read or write the protected memory . 

As I searched through internet ,many opinions suggests, it is problem of marshalling the data from unmanaged code to managed code. 

Is there effective way to return a string from Dll to c# application. I have struck with this from many days. Any possible help is highly appreciable.! Thank You!!!

Similar questions and discussions