Search code examples
c++-climanaged

C++/CLI 'ToInt32': is not a member of 'System::UInt32'


As the title says i am getting this error when trying to do the following...

DWORD nWritten = 0;
::WriteProcessMemory(GetCurrentProcess(), hookTarget, hookBytes, HLength, &nWritten);
Console::WriteLine(nWritten.ToInt32);

Solution

  • You just need to cast the DWORD:

    System::Console::WriteLine((System::Int32)nWritten);
    

    Here DWORD is native, but you were trying to use a managed method on that, which won't work.