No really sure why it would work in second example and not in the first. One thing you have to be careful when dealing with calls like this is to make sure they happen on the main 3dsmax thread. If you try to invoke the DIB property from another thread, for example, you can get errors/crashes. That is why ISynchronizeInvoke is passed into plugin along with IGlobal.
Other than that I use gw.DIB all the time, but I do catch access violation exceptions which occur rarely (and are caused by some invalid 3dsmax setups):
try
{
bitmap = viewportContext.GraphicsWindow.DIB;
}
catch( System.AccessViolationException )
{
allowResizeViewport = false;
Plugin.Log( Plugin.LogType.Warning, "Error retrieving bitmap" );
}
Marsel Khadiyev (Software Developer, EPHERE Inc.)