struct DeviceParam {
 UINT32 count;
    UINT32 selection;
 wchar_t *MyStrings[MAX_DEVICES];
_declspec(dllexport) int Device(DeviceParam *objnew)
     wchar_t *temp[MAX_DEVICES];
     objnew->MyStrings[0] = L"Device1";
  temp[0]= L"Device2";
  int size_t = wcslen(temp[0]);
     wchar_t *ptr;
  ptr=wmemcpy( objnew->MyStrings[0], temp[0], size_t);
when i compile the code i get the following error ,
An unhandled exception of type 'System.AccessViolationException' occurred in TestLib.exe

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
where i am doing wrong ?