Search code examples
wpfrendertargetbitmap

RenderTargetBitmap renders empty images


Here's the situation: I have an ASP.NET Web Forms application which uses WPF controls for reporting.

Process is the following: Create WPF controls and bind to data -> create image from WPF control -> use generated image to create PDF reports.

I'm using RenderTargetBitmap to render bitmaps from WPF controls. Issue is when I run all this on my local machine (Windows 10) it works, as soon as application is deployed on QA machine (Windows Server 2008 R2) it generates empty images.

I tried to simplify reporting page, by leaving only static text on the WPF control, still I get empty page.

I created sample console application which mimics part of binding data to WPF (granted static data) and generating image from WPF control & it works on both environments. One difference I can think of is the console application is not running as IIS' AppPoolIdentity, which runs the Web Application on the QA machine.

I came across this SO post which suggests there was a Windows Update that caused similar issue. Our QA machine is Azure VM, so updates are installed regularly. Update that caused the issue is from September 2017, having fix update out in October 2017. So I rulled out windows update causing the issue.

Also in the referenced SO post, OP suggests that this issue happens only if account running the code is System account

It ONLY doesn't work if run under high privilege SYSTEM account (e.g. from Task scheduler).

I tried this as well, having Task Scheduler running the sample console app, but as I mentioned above it successfully created the image.

So at this moment I'm pretty much out of ideas.

The application code that is supposed to generate images is scattered so I'm not sharing it here, but if any piece is of particular interest happy to post.

Any idea what can cause this different behavior in diff. environments ?


Solution

  • It turns out ruling out missing Windows Update was not the right thing to do. At the end I installed the fix windows update and issue was solved.