by following code , I get at the end an error "Unhandled exception at 0x1000693a in IntensityRange.exe: 0xC0000005: Access violation reading location 0xcdcdcdd1." in VS.

Code :
template<typename TReferenceImage, typename TAlignImage>
void ImageSimilarityMetricMutualInformationGPU<TReferenceImage,TAlignImage>::
    size_t localWorkSize[2], globalWorkSize[2];
	unsigned int WORKGROUP_COUNT = 256;
	localWorkSize[0] = WORKGROUP_COUNT;
    localWorkSize[1] = 1;
    globalWorkSize[0] =  WORKGROUP_COUNT*localWorkSize[0];
    globalWorkSize[1] = 1;
   clSetKernelArg(m_ckHistogram256, 7, sizeof(cl_mem), 
                         (void *)&m_cl_device_Transformation);
    clEnqueueNDRangeKernel(m_cqCommandQue, m_ckHistogram256, 2, NULL, 
                                      globalWorkSize, localWorkSize, 0, NULL, NULL);

I get the error at the end by clEnqueueNDRa....

At this point, no variables are NULL, so I cannot understand the problem. I have a first version of the same code which is working fine. The only difference between them is, that the first version takes cl_command_queue cqCommandQue, cl_kernel ckHistogram256, as parameters and everything works fine. Now, my second version of code has a class and the variable , which are given as parameters in the first version, are now member variables of the class (they are already initialized and everything). There are no other changes , everything is the same. Why does my first version works fine whereas the second one does not ? Is there any openCL policies like "not allowed to hold cl_command_queueu or cl_kernel as member variables of a class" ???