   [.net] Cannot marshal 'return value'
  Hey all, I'm trying to write a simple class to obtain some info about OpenGL on the user's system. class OpenglInfo {/*OpenGL Constants*/public const uint GL_VENDOR = 0x1f00;public const uint GL_RENDERER = 0x1f01;public const uint GL_VERSION = 0x1f02;public const uint GL_EXTENSIONS = 0x1f03;[DllImport("opengl32.dll")]public static extern byte[] glGetString(uint name); }And I'm calling it like this:String gl_version = BitConverter.ToString( OpenglInfo.glGetString(OpenglInfo.GL_VERSION) )The problem is, I'm getting a .NET runtime error: "Cannot marshal 'return value': Invalid managed/unmanaged type combination."  And thats it.  I'm not sure what I'm doing wrong.   
  Try with:public static extern String glGetString(uint name);;  Thanks for the reply.  Turns outs you need to create a GL context before you can call glGetString.  Creating the GL context fixed the problem.   ;  Don't try to return a string directly, this will crash. Instead, return an IntPtr and use Marshal.PtrToStringAnsi() to marshal the value into a string (you can do this transparently with a wrapper function).   