简体   繁体   中英

Bogus Exception from SSRS when rendering to MHTML in C#

Environment is SQL Server 2008 Web Edition on Windows 2008 server. SSRS is installed and working - ie I can view, refresh and export reports from the report manager.

Due to the constraints of this version I have written a simple ASP.NET wrapper to render the report and email it to me. This works great with HTML or PDF. I want to render it to MHTML and blat this into an email - this also works the first time I run it. On subsequent occasions, unless I stop and restart the SSRS service in the config manager I get:

You have attempted to use a rendering extension that is either not registered for this report server or it is not supported in this edition of Reporting Services. (rsRenderingExtensionNotFound)

Clearly that is not true, it is registered and it does indeed work. If I switch to rendering to one of the former formats I can run the render as many times as I like. I am wondering if there's some part of the file system being used and maybe a cache file sitting around between times? The symptom is a bit like needing an Application Pool refresh when an ASP.NET app has used a file.

The code that actually executes is:

byte[] bytes = ReportViewer1.ServerReport.Render("MHTML", null, out mimeType, out encoding, out extension, out streamids, out warnings);

I'm not sure what to try next, I really want it to render MHTML because when I split that out into an email I get a perfect rendition of my reports directly in the email body.

Help! TIA, M

So the official answer is that it won't work - Web Edition at least disabled the render to MHTML as part of its configuration. It seems to be a bug that this only happens after a report has been processed and indeed it will succeed the first iteration and fail on others.

I ended up rendering to HTML, parsing out the image SRCs, grabbing them as image streams and attaching these to the email, replacing the URLs with cid:s All works very nicely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM