WebBrowser.DrawToBitmap() doesn't render the image - c#

I have got into a strange situation and couldn't find a reason or resolution to it. I have a utility that creates a jpg image out of an HTML content. It is using WebBrowser.Navigate(url) and WebBrowser.DrawToBitmap() methods.
This utility has been working for a year or more by different clients on their servers. Now, one of them which could get desired images until few weeks ago, getting strange images. The image just shows the URL that I am passing to the Navigate() method. I could render the correct image from the same URL on my local machine. I checked the DocumentText property of the object and the contents was there and all the width and height was OK and no error is generated anywhere. Only the image doesn't make any sense. It is not related to the HTML contents and does the same behavior for all pages.
Does anyone knows what could be changed that caused this issue to happen? Although they have recently upgraded from Server 2008 to 2012, they claim that this rendering stopped before the upgrade. My code has not been touched. The project is built with C# and .NET 4.0.
Any help or comments is appreciated.
Behzad

It may be because of KB3057839 which has broken DrawToBitmap:
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/9d690398-1f91-4fbd-82fa-4b663c3b558f/kb3057839-has-broken-windows-forms-controldrawtobitmap-when-called-from-application-launched-from?forum=windowsgeneraldevelopmentissue

Since this issue was introduced using the security update patch "KB3057839" . Microsoft has again released a few set of patches on July 14(Please check https://technet.microsoft.com/en-us/library/security/ms15-jul.aspx). The patch "KB3070102" resolves the issue and can be downloaded from https://technet.microsoft.com/library/security/MS15-073.

Related

Facebook/Workplace Graph API: Error posting image to album

Several years ago I wrote an app that watches a file share for incoming PDFs, extracts all images from the PDF, creates an album on a Workplace page, and posts the images to that album. This has been working fine for years, but suddenly, on May 24th, it started failing with a 500 Internal Server Error when POSTing the images. Has there been some kind of change to the Graph API that can explain this? I'm basically POSTing (using WebClient.UploadFile) to https://graph.facebook.com/ALBUM_ID/photos?access_token=ACCESS_TOKEN. According to the Access Token Debugger at https://developers.facebook.com/tools/debug/accesstoken/ my app has the following Workplace Integration Permissions: read_group, write_group, link_unfurling. Any and all hints appreciated!
Looks like this may be caused by a known issue: https://developers.facebook.com/support/bugs/422557782692044/ Even though this refers to endpoint {groupId}/photos, according to this thread https://developers.facebook.com/support/bugs/1167214814122516/?join_id=f376b4bd2da9ff8, failing POSTs to {albumId}/photos are caused by the same issue. Also, the reported Last Known Working Date of May 23 2022 fits perfectly with our experiences.

visual studio does not apply css

I wanted to make a small test site using the Metro UI framework (http://metroui.org.ua/)
So, I started up my newly installed Visual Studio 2013 and started a "new website". I added the neccesary css and js and made a very basic masterpage and default.aspx. But here comes the problem: the css does get loaded, but it doesn't get applied. Not in FireFox, not in IE, not in Chrome and not in the "Page Inspector".
It's quite weird, because in my previous VS2012 this same workflow for testing and experimenting with a framework just worked. I really can't find the problem. Maybe it has to do with my new Windows 8.1, my new Visual Basic 2013, maybe an programming error (although that would be very unlikely, since I checked everything).
I also tried installing the framework using NuGet instead of manually adding it. Same result: it does load, but it doesn't get applied.
Anyone knows what's happening here?
Thanks in advance!
According to MetroUI you have to follow 5 simple steps
Create page with HTML5 DOCTYPE
2.Include metro-bootstrap.css
Include metro.min.js (jquery.js required)
Create main container with class .metro
Use markup, as described in the pages of this site
In your posted images I can't find a container with class .metro . I'd really check the sample code from the posted page.
In case I misunderstood anything please let me know!

Inherited an ASPX site and cannot change a variable

I just inherited an ASPX site from a new customer of mine. I know ASP but I cannot figure this one out. There are two pages that seemingly do exactly the same thing (cause they should) they both read an XML file and pull in the correct child datasets 2010 for the 2010 data and 2011. I need to add a new set for their 2012 line.
I figured I could dupe one of these pages and change the "2011" to "2012." The problem is I cannot find the "2011" ANYWHERE! the only difference between the two files is:
There isn't a "year2011.aspx.cs" to be found via FTP that I can see and changing the 2011 to 2012 just throws an error. Reading up a little on the CodeBehind tag there pointed me to a few DLLs that ARE there BUT I have no idea how to edit them to make them work. Their old developer did not leave anything but what was on the server.
Any ideas on what I can do to make this work?
It seems the code is compiled so there wont be any *.cs files. If you haven't got the source code as you have mentioned you will need to decompile the DLL's to allow you make any necessary edits.
Take a look at http://www.telerik.com/products/decompiler.aspx , it will allow to decompile the dll back to *.cs files to allow you to make any edits.
Once you have the source code you should be able to debug and provide more information about the error you are experiencing

problem with image display in visual studio

I have got a strange problem. Can somebody look into it please.
I have a folder called "img" in my website. I added a new image to it.
Now the strange problem is that when I give img/imagename.extension it doesn't display in the browser.
I have tried even ~/img. But ended nothing. Actually I am using the image in the spark template. I have taken an existing image and tried, it displays the existing image but not the one I have added. I was expecting may be I need to check in the newly added image but even doing that didn't end up the result.
Any ideas????
Thanks
if you using Razor use #Url.Content("~/img/yourimage.ext")
Check if authorisation rules of the folder img prevent the images from being shown e.g. to not authorised users.
Check if the image file was properly added to the solution in the VS.

Caputuring a Silverlight Bing Map as an image

The WriteableBitmap class that was introduced in Silverlight 3 does not allow images to be rendered from a different domain for security reasons and hence it is impossibe to output an image of the Bing Map.
Does anyone have any suggestions for a workaround? I just want to capture a snapshot of the image including the controls and shapes I have drawn on the overlying canvas
Thanks
Paul
There is a workaround - the bing maps silverlight control allows you to specify a custom configuration. In this configuration, you can specify your own URLs for images, and make them so that they are not cross-domain, and hence not "insecure".
However, there is a bug in Silverlight which causes the workaround to fail. See here: https://connect.microsoft.com/VisualStudio/feedback/details/628962/
The sample attached to the bug report in the link above shows how to specify a custom map control configuration.
Did you try Bing's Imagery Service? See
http://msdn.microsoft.com/en-us/library/cc966738.aspx
It would be shame if something that is inplace for good security reasons could then be worked around, wouldn't it?
It may be that your true goal might be achievable using some other approach but you don't state what that is.
For example, you might want to generate some simple image that can then be hosted on a web site to be downloaded. A possible workaround would be to use the Silveright print API to print the desired content. Use a PDF generating printer driver you could then upload the generated PDF to the site
Of course this example may be far from your purpose. State your intent and a more lateral work around may be offered or at least a definitive, "no you can't".

Categories

Resources