Wednesday 15 May 2013

c# - Intermittently Access Violation Exception when calling the OpenCL function GetPlatformIDs via DLL call -


I use'm writing an application in C # which Opansiel I use functions directly using an existing casing I want to do as I did in the past with other DLLs. When I function GetPlatformIDs phone I intermittently the following error:

  AccessViolationException An attempt was made to write to the reading process or protect memory without. It is often a sign that the other memory is corrupt.  thought 

I started there was an error in my DLL call so I try to look at other examples of other sites and code from open source projects, but they all behave the same with them Were. If the code can find the initial call then everything else will work, but 50% of the time fails on that call. To illustrate this problem, I have followed the bare bone sample:

  using the system; Using System.Runtime.InteropServices; Namespace openclerrortest {class Program {[DllImport ( "OpenCL.dll", EntryPoint = "clGetPlatformIDs", ExactSpelling = true)] internal exile stable unsafe integer _GetPlatformIDs (uint num_entries, IntPtr * platforms, uint * NUM_PLATFORMS); Static Unprotected Zero Test () {UIT Newsflats; Int ec = _GetPlatformIDs (0, (IntPtr *) IntPtr.Zero.ToPointer (), and amp; numOfPlatforms); } Static zero main (string [] args) {test (); }}}  

Here is a stack trace when it crashes: (UInt32 num_entries, intPtr * platforms, UInt32 * NUM_PLATFORMS on openclerrortest.program._GetPlatformIDs) (

  Openclerrortest.Program.Test (at C): \ Users \ My \ Documents \ Visual Studio 2005 \ Projects \ openclerrortest \ openclerrortest \ Program.cs: OpenCellortest.Program.Main on Line 14 (String [] args): \ Users \ MY \ DOCUMENTS \ Visual Studio 2005 \ Projects \ openclerrortest \ openclerrortest \ Program.cs: On Line System.AppDomain._nExecuteAssembly 19 (assembly assembly, string [arg]) on System.AppDomain.ExecuteAssembly (str On the Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly () in the System.Threading.ThreadHelper.ThreadStart_Context (object state) in the assemblyfile, Evidence AssemblySecurity, System.Threading.ExecutionContext.Run (executionContext executionContext, ContextCallback callback, Object state) in the system String [] args) .reading.ThreadHelper.ThreadStart ()  

Any help would be greatly appreciated Ated.


No comments:

Post a Comment