System.Runtime.InteropServices.SEHExceptionon addLayout

Hi,

I tried to run the example frmo the link: http://developer.rhino3d.com/samples/rhinocommon/addlayout/, but I end up with SEH exception. I have executed the method with this input:
var doc = RhinoDoc.ActiveDoc;
AddLayout(doc);

What am I doing wrong?

Edit:

Maybe the reason is that I used it inside background worker, my mistake.

Using a background thread for this is definitely why the exception is occurring.