1

我有一个 WPF 应用程序生成一些报告。我需要从 WindowService 启动此应用程序,而我目前正在从作为 LocalSystem 运行的服务执行该应用程序。除 Pie 3d 外,所有渲染均已正确完成,显示在 Viewport3D 对象中。这是显示行为的代码提取:

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);
            }
        }
    }

这是调用代码:

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

是的,视口是正确测量/排列的。

从 3d 对象的非交互式应用程序渲染是否有一些限制,我在 Windows7 - 2008 服务器环境中。? 有什么解决方法吗?

4

1 回答 1

0

不幸的是,由于这项政策:

在 Windows XP®、Windows Server® 2003 和早期版本的 Windows® 操作系统中,所有服务都在与登录控制台的第一个用户相同的会话中运行。此会话称为会话 0。在会话 0 中同时运行服务和用户应用程序会带来安全风险,因为服务以提升的权限运行,因此是寻求提升自己权限级别的方法的恶意代理的目标。


Windows Vista® 和 Windows Server® 2008 操作系统通过隔离 Session 0 中的服务并使 Session 0 非交互来降低这种安全风险。在 Windows Vista 和 Windows Server 2008 中,只有系统进程和服务在 Session 0 中运行。第一个用户登录到 Session 1,后续用户登录到后续会话。这种方法意味着服务永远不会与用户的应用程序在同一会话中运行,因此可以防止源自应用程序代码的攻击。

在 Windows 7 2008 上,所有涉及视频驱动程序的渲染都会失败。所以唯一的解决方案是让应用程序公开服务并在桌面上运行。

于 2013-02-05T14:09:17.153 回答