Question

I've a WPF application generating some reports. I need to launch this application from a WindowService, and I'm currently executing that from a service running as LocalSystem. All the rendering is done properly, except for a Pie 3d, display in a Viewport3D object. This is a code extraction showing the behavior:

static class VisualSaver
    {
        public static void Save(Visual v, int width, int height, string file,Brush background)
        {
            RenderTargetBitmap bmp = new RenderTargetBitmap(
                        width, height, 96, 96, PixelFormats.Pbgra32);

            Rectangle vRect = new Rectangle();
            vRect.Width = width;
            vRect.Height = height;
            vRect.Fill = background;
            vRect.Arrange(new Rect(0, 0, vRect.Width, vRect.Height));

            bmp.Render(vRect);
            bmp.Render(v);

            PngBitmapEncoder png = new PngBitmapEncoder();
            png.Frames.Add(BitmapFrame.Create(bmp));

            using (Stream stm = File.Create(file))
            {
                png.Save(stm);
            }
        }
    }

And this is the calling code:

VisualSaver.Save(viewport,310,340,PathExtension.GetTempFileWithExtension("png"),Brushes.White);

And yes the viewport is properly Measured / Arranged.

Are there some limitation in rendering from non-interactive applications of 3d objects,I'm in Windows7 - 2008 server env. ? Are there any workaround?

Was it helpful?

Solution

Unfortunately due to this policy:

In Windows XP®, Windows Server® 2003, and earlier versions of the Windows® operating system, all services run in the same session as the first user who logs on to the console. This session is called Session 0. Running services and user applications together in Session 0 poses a security risk because services run at elevated privilege and therefore are targets for malicious agents that are looking for a means to elevate their own privilege levels.


The Windows Vista® and Windows Server® 2008 operating systems mitigate this security risk by isolating services in Session 0 and making Session 0 non-interactive. In Windows Vista and Windows Server 2008, only system processes and services run in Session 0. The first user logs on to Session 1, and subsequent users log on to subsequent sessions. This approach means that services never run in the same session as users' applications and are therefore protected from attacks that originate in application code.

On windows 7 2008 all renders involving the video drivers fails. SO the only solution is to have the app exposing a service and run on a desktop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top