A
A
Alexander Yudaev2011-11-16 03:25:44
C++ / C#
Alexander Yudaev, 2011-11-16 03:25:44

Windows services, C# and OpenCL.dll?

Hello habrohumans!
I'm writing a Windows Service that, among other things, checks for OpenCL devices on the system. For this check, the already installed OpenCL.dll library is used, namely, the clGetPlatformIDs function .
The problem is that after calling this function, there is no return to the program. The service hangs for a while, after which it is killed by Windows (timeout). No exceptions are thrown.
The service runs as LocalSystem.
I import like this:

[DllImport("OpenCL.dll")]
        public static extern int clGetPlatformIDs(
                    uint num_entries,
                    [MarshalAs(UnmanagedType.LPArray)] System.IntPtr[] platforms,
                    out uint num_platforms);

I use like this:
int error;
            uint numPlatforms;

            error = Test.clGetPlatformIDs(0, null, out numPlatforms);

Tried to use different calling conventions (CallingConvention), no results.
The project also uses the libraries kernel32.dll, advapi32.dll - there are no problems with them.
If I insert the above code into a regular console project, everything works like clockwork.
Explain, please, what I'm doing wrong and where should I dig. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question