Hello All. Im using modified code from Windows Media Server SDK sample to create a plugin for direct logging to database. All elements of the code work except where it goes to get the logs from server, that part always ends up with a error no matter what is done. Original SDK sample code file name: VBDBLoggingPlugin.vb Enviroment; Windows Server 2008 Enteprirse, Media Services for Server 2008, Visual Studio 2008 Namespace imports; Imports WMSServerLib Imports System.Text Imports System.Runtime.InteropServices Imports Microsoft.Win32 Calling code; CommandCtx.GetCommandRequest(CommandRequest) CommandRequest.GetIUnknownValue( "@WMS_COMMAND_CONTEXT_BODY", 11, ContextBody, 0) NsBuffer = ContextBody If NsBuffer Is Nothing Then Exit Sub End If strContext = GetStringFromNSSBuffer(NsBuffer) Function (where error occures) ; Private Function GetStringFromNSSBuffer(ByRef NsBuffer As INSSBuffer) As String Dim s As String = "" GetStringFromNSSBuffer = "" Try Dim uBufSize As UInt32 Dim pbuf As IntPtr = New IntPtr() NsBuffer.GetBufferAndLength(pbuf, uBufSize) Dim iBufSize As Int32 = Convert.ToInt32(uBufSize) / 2 s = Marshal.PtrToStringUni(pbuf, iBufSize) GetStringFromNSSBuffer = s Catch End Try End Function Error; Value does not fall within the expected range.