You must specify the initial capacity for your StringBuilder (via the constructor) to ensure it is big enough to store the result. You are calling the default constructor.
you can, instead, pass a System.Text.StringBuilder object; a pointer will be passed by the marshaler into the unmanaged function that can be manipulated. The only caveat is that the StringBuilder must be allocated enough space for the return value, or the text will overflow, causing an exception to be thrown by P/Invoke.
StringBuilder ID_buf = new StringBuilder(MaxVersionLength);