QPaintDevice: Cannot destroy paint device that is being painted pure virtual method calledterminate called without an active exception - wkhtmltopdf

I am working with ASP.NET MVC. PDF output is running in debug mode with Rotativa.But when I throw it to the server I get the above error.I tried all versions of rotativa and wkhtmltopdf.
If I don't add headers to the output it works well on both sides.
CustomSwitches = string.Format("--header-html "{0}" --header-spacing 10 --footer-html "{1}"", header, footer)

I added the IP of the site to the host file. Problem solved.
See : https://cpanelplesk.com/how-to-edit-hosts-file-on-your-system/

Related

How to convert IHTMLImgElement to image

I am automating Internet Explorer using SHDocVW.dll and MSHTML with C#, and I wish to save an image from the page to the disk (JPEG format).
I can't use the WebClient class to download the image; if I do it, I end up downloading the site's login page. I can't print the screen either, because the browser has to remain invisible during this process, running in the background.
I have tried to do the following:
IHTMLImgElement imgElement = ...;
IHTMLControlRange imgRange = ...;
imgRange.add(imgElement as IHTMLControlElement);
imgRange.execCommand( "copy", false, null );
This does nothing. I am not able to extract anything from the clipboard. Every solution I found didn't work for me.
Your webclient approach is probably missing cookies... see How do I log into a site with WebClient? for an example that handles cookies.
your code looks fine except the user has to change the security setting to enable clipboard access. If the image is cached on disk you can dig the WinInet cache after parsing the page for the image location.

MiniProfiler with ASP.NET WebForms Classic Mode

We're trying to configure MiniProfiler with an ASP.NET WebForms app that runs in a classic mode app pool (cannot change it to integrated). We couldn't get the handlers to work so loading the resources failed.
To solve this we included the .js, .css, .tmpl, and .html from https://github.com/SamSaffron/MiniProfiler/tree/master/StackExchange.Profiling/UI After doing that these resources get loaded, but we still don't see anything.
The initialization script is rendered in the final html, but the ... block never gets generated. I'm assuming because the script never runs. We tried loading jQuery v1.7.1 and a newer version; neither worked.
There are no 404s or anything in the console (Chrome or FireFox). Any ideas? Thanks.
Are you having the issue running the profiler in IIS on your local machine or on a server?
The quick code sample on the miniprofiler.com site suggests wrapping the MiniProfile.Start() call in a Request.IsLocal condition (code below), this would prevent the profiler from being rendered on the server (unless you were viewing the page from the server itself). Try removing the Request.IsLocal code and see if that helps.
protected void Application_BeginRequest()
{
if (Request.IsLocal)
{
MiniProfiler.Start();
}
}

Watin accessing localhost

When executing the c# code in MSTest involving WatiN
var browser = new IE("http://localhost:56034/");
The web page is displayed in IE but after about a minute, I receive the error
Timeout while waiting for main document becoming available with the error message
Timeout while waiting for main document becoming available
The code
var browser = new IE("http://www.bing.com/");
works fine.
I am running IIS Express 7.5. Since I am new to the WatiN I am hoping that I am missing something simple.
Following the advice in http://spin.atomicobject.com/2010/12/15/watin-and-com-errors-enable-ie-protected-mode-for-local-intranet-zone, turning ON protected mode for the intranet zone in IE 8 solved the problem.

Problems with jQuery getJSON using local files in Chrome

I have a very simple test page that uses XHR requests with jQuery's $.getJSON and $.ajax methods. The same page works in some situations and not in others. Specificially, it doesn't work in Chrome on Ubuntu.
I'm testing on Ubuntu 9.10 with Chrome 5.0.342.7 beta and Mac OSX 10.6.2 with Chrome 5.0.307.9 beta.
It works correctly when files are installed on a web server from both Ubuntu/Chrome and Mac/Chrome (try it out here).
It works correctly when files are installed on local hard drive in Mac/Chrome (accessed with file:///...).
It FAILS when files are installed on local hard drive in Ubuntu/Chrome (access with file:///...).
The small set of 3 files can be downloaded in a tar/gzip file from here:
http://issues.tauren.com/testjson/testjson.tgz
When it works, the Chrome console will say:
XHR finished loading: "http://issues.tauren.com/testjson/data.json".
index.html:16Using getJSON
index.html:21
Object
result: "success"
__proto__: Object
index.html:22success
XHR finished loading: "http://issues.tauren.com/testjson/data.json".
index.html:29Using ajax with json dataType
index.html:34
Object
result: "success"
__proto__: Object
index.html:35success
XHR finished loading: "http://issues.tauren.com/testjson/data.json".
index.html:46Using ajax with text dataType
index.html:51{"result":"success"}
index.html:52undefined
When it doesn't work, the Chrome console will show this:
index.html:16Using getJSON
index.html:21null
index.html:22Uncaught TypeError: Cannot read property 'result' of null
index.html:29Using ajax with json dataType
index.html:34null
index.html:35Uncaught TypeError: Cannot read property 'result' of null
index.html:46Using ajax with text dataType
index.html:51
index.html:52undefined
Notice that it doesn't even show the XHR requests, although the success handler is run. I swear this was working previously in Ubuntu/Chrome, and am worried something got messed up. I already uninstalled and reinstalled Chrome, but that didn't help.
Can someone try it out locally on your Ubuntu system and tell me if you have any troubles? Note that it seems to be working fine in Firefox.
Another way to do it is to start a local HTTP server on your directory. On Ubuntu and MacOs with Python installed, it's a one-liner.
Go to the directory containing your web files, and :
python -m SimpleHTTPServer
Then connect to http://localhost:8000/index.html with any web browser to test your page.
This is a known issue with Chrome.
Here's the link in the bug tracker:
Issue 40787: Local files doesn't load with Ajax
On Windows, Chrome might be installed in your AppData folder:
"C:\Users\\AppData\Local\Google\Chrome\Application"
Before you execute the command, make sure all of your Chrome windows are closed and not otherwise running. Or, the command line param would not be effective.
chrome.exe --allow-file-access-from-files
You can place your json to js file and save it to global variable. It is not asynchronous, but it can help.
An additional way to get around the problem is by leveraging Flash Player's Local Only security sandbox and ExternalInterface methods. One can have JavaScript request a Flash application published using the Local Only security sandbox to load the file from the hard drive, and Flash can pass the data back to JavaScript via Flash's ExternalInterface class. I've tested this in Chrome, FF and IE9, and it works well. I'd be happy to share the code if anyone is interested.
EDIT: I've started a google code (ironic?) project for the implementation: http://code.google.com/p/flash-loader/
#Mike On Mac, type this in Terminal:
open -b com.google.chrome --args --disable-web-security
This code worked fine with sheet.jsonlocally with browser-sync as the local server.
-But when on my remote server I got a 404 for the sheet.json file using Chrome.
It worked fine in Safari and Firefox.
-Changed the name sheet.json to sheet.JSON. Then it worked on the remote server.
Anyone else have this experience?
getthejason = function(){
var dataurl = 'data/sheet.JSON';
var xhr = new XMLHttpRequest();
xhr.open('GET', dataurl, true);
xhr.responseType = 'text';
xhr.send();
console.log('getthejason!');
xhr.onload = function() {
.....
}

Register an application to a URL protocol (all browsers) via installer

I know this is possible via a simple registry change to accomplish this as long as IE/firefox is being used. However, I am wondering if there is a reliable way to do so for other browsers,
I am specifically looking for a way to do this via an installer, so editing a preference inside a specific browser will not cut it.
Here is the best I can come up with:
IE: http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx
FireFox: http://kb.mozillazine.org/Register_protocol
Chrome: Since every other browser in seems to support the same convention, I created a bug for chrome.
Opera: I can't find any documentation, but it appears to follow the same method as IE/Firefox (see above links)
Safari: Same thing as opera, it works, but I can't find any documentation on it
Yes. Here is how to do it with FireFox:
http://kb.mozillazine.org/Register_protocol
and Opera:
http://www.opera.com/support/kb/view/535/
If someone looks like a solution for an intranet web site (for all browsers, not only IE), that contains hyperlinks to a shared server folders (like in my case) this is a possible solution:
register protocol (URI scheme) via registry (this can be done for all corporative users i suppose). For example, "myfile:" scheme. (thanks to Greg Dean's answer)
The hyperlink href attribute will then should look like
<a href='myfile:\\mysharedserver\sharedfolder\' target='_self'>Shared server</a>
Write a console application that redirects argument to windows explorer (see step 1 for example of such application)
This is piece of mine test app:
const string prefix = "myfile:";
static string ProcessInput(string s)
{
// TODO Verify and validate the input
// string as appropriate for your application.
if (s.StartsWith(prefix))
s = s.Substring(prefix.Length);
s = System.Net.WebUtility.UrlDecode(s);
Process.Start("explorer", s);
return s;
}
I think this app can be easily installed by your admins for all intranet users :)
I couldn't set up scheme setting to open such links in explorer without this separate app.

Resources