When allocating memory and writing to it, it fails to actually write to it can anyone help spot my error here?

When allocating memory using:

 [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
            internal static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, UInt32 flAllocationType, UInt32 flProtect);

internal static int AllocateMemory(int memorySize)

            return (int)NativeMethods.VirtualAllocEx(ProcessHandle, (IntPtr)0, (IntPtr)memorySize, 0x1000, 0x40);

internal static void WriteBytes(int address, byte[] value)
            bool success;
            UInt32 nBytesRead = 0;
            success = NativeMethods.WriteProcessMemory(ProcessHandle, (IntPtr)address, value, (IntPtr)value.Length, ref nBytesRead);
private void button1_Click(object sender, EventArgs e)
        int allocatedmemory = AllocateMemory(1000);
        WriteBytes(allocatedmemory, new byte[] {0x30, 0x30});

I am attempting to allocate memory into a process, and then to write to the allocated memory, however it fails to write to the allocated memory and I don't know why maybe someone else could spot the error?

This is my first time attempting process reading/writing.