How to solve "Qt: Could not initialize OLE (error 80070005)" issue - c#

I am using Rotativa to generate PDF in my Application. It's working fine in my application localhost (Development). I got the "Qt: Could not initialize OLE (error 80070005)" error once, i have deployed in my server. How to solve this issue. Thanks advance

Go to IIS > Site > Authentication, click on "ASP.NET Impersonation" and DISABLE it

I found the problem here-
https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2782
We started by removing all assets (css and javascript) from the document - leaving just images and the html layout. It generated correctly through IIS. We then slowly added back resources, starting with CSS. The moment we added one of our Javascript files back it threw the OLE error again. We removed that and added some simple Javascript to the document (literally var x = 1;) and it still failed.
For some reson wkhtmltopdf cannot find js files...
so i found the solution here-
https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1634
I simply had to change:
<script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js"></script>
to:
<script src="http://cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js"></script>
(added the HTTP).
I also switch on server from ActionAsPdf to UrlAsPdf
And set the url to localhost
string pthx = "http://localhost/Home/exmple?num=" + numtofind;
UrlAsPdf urlss = new UrlAsPdf(pthx) {
FileName = "REPORT.pdf",
CustomSwitches = "--print-media-type "
};
I think the wkhtmltopdf can't find host...
Hope it will help you too...

Related

Blazor Server Path Issues

I hope someone can help I'm still pretty new to Blazor and I've been struggling with this problem all day.
I had a Blazor Server app that ran fine on my local machine and also fine on my deployment server (Ubuntu/with Apache proxy). It ran fine for months until I needed to move it from the root of the server to a subfolder e.g. https://myserver/myapp. That's when my nightmare began. Even though all the content paths are relative for css, images etc they were all trying to load from the root / of the website after I moved it.
There's several ways I have found for setting the path of the app.
app.UsePathBase("/myapp")
app.UseStaticFiles("/myapp")
Setting these seem to be completely ignored when deployed on the server for some reason so I had to look for other options. I then found that you can simply set the path in the tag in _Layout.cshtml:
<base href="/myapp/" />
This worked great... all the content loaded as intended and I thought it was fixed until I realised none of the dynamic js elements was working.
I tracked that down to a incorrect path in the script tag "/_framework/blazor.server.js" so I corrected the script tag to be "_framework/blazor.server.js".
Now its trying to load the script from https://myserver/myapp/_framework/blazor.server.js - the problem is that path does not exist! Yet somehow it works fine on my local dev environment.
I've tried many things... even copying the _framework folder from my local environment to wwwroot manually - which resulted in some strange errors and did not seem like a good idea.
I've also tried using ~/ as the base href which works locally but breaks on the server where it's just trying to serve everything from the root folder again.
I don't understand why things are working very differently in the development environment and the published server build. I also can't seem to change where that _framework folder is located and so can't load the necessary script files.
Is it something you do with the app.MapBlazorHub() command?
Adding the code below to your _layout file configures the signalR hub to use an absolute path instead of a relative path:
<script src="~/_framework/blazor.server.js" autostart="false"></script>
<script>
Blazor.start({
configureSignalR: function (builder) {
builder.withUrl("/_blazor");
}
});
</script>
Now, you can use your absolute path for it.
In the end I worked around this by placing my app on it's own subdomain myapp.myserver.com. It doesn't really solve the original problem but Blazor Server apps just seem to work with much less hassle when they are in the located in the root path.

Unable to determine if a file is on a web server because the various methods of determining the directory do not work

I am developing an application in asp.net, vs2015 using c# and the development environment is a Win10Pro machine. I can use any of the various methods to obtain the working directory and see if a particular file exists on the dev pc, but not on the Web Server. I have tried the methods laid out on:
Get current application physical path within Application_Start
All work on the Dev PC, but when used on the Web Server it will not return the working directory. The Server is a 2016 Data server using IIS10. The issue is that the web site I am putting together work fine, except to display GrapeCity ActiveReports reports AR15. The web page containing their web viewer opens just fine and is looking for a report file (MyReport.rdlx). The global.aspx file is pointing to the root directory but when the web viewer opens up, it says File Not Found. I have absolutely no idea and tech support is not sure. Is this an IIS issue that is preventing the code to locate and verify the file is there? Any direction would be much appreciated. This has been very frustrating and time consuming.
AppDomain.CurrentDomain.BaseDirectory does not work, HttpRuntime.AppDomainAppPath does not as well as all the others. The request comes back blank.
string filename = AppDomain.CurrentDomain.BaseDirectory.ToString() +"SPU01_Dates.rdlx";
if (File.Exists(filename))
{
Response.Write("YES");
}
else
{
Response.Write("NO");
Response.Write("</br");
Response.Write(filename);
}
All this just returns nothing.
Thanks.
Try this code
if (File.Exists(Server.MapPath(filename)))
Check if a file exists on the server
In my test, it returned YES and worked well. Did you put "SPU01_Dates.rdlx" file in root folder?
In the development environment, it returned YES, and when I deployed it to IIS, it returned NO. I found that during the deployment process, the rdlx file was not deployed with the project, so I recreated one in the deployed folder, and it returned YES.
The test proves that AppDomain.CurrentDomain.BaseDirectory is the most accurate way to get the file path. When you test this code in IIS, does it return NO or empty? Returning empty means that this piece of code has not been executed.

Why would Azure Search Indexer stop working on a Live app

I have a .Net/C# app that calls the Azure Search Service. It's been working fine to find a list of PDF files I have in Azure storage based on keywords submitted. But a couple of days ago, the live app on Azure stopped working - no documents are returned from a search. However, on Local, the app works fine with the same code. I'm suspecting something may have changed with firewall rules, but I can't find where that may have occurred. Hopefully someone has had something similar happen and has a solution.
Here's the code that stopped working on Live.
var indexClient = GetIndexClient(); // sets up SearchIndexClient with uri, credentials, etc.
SearchParameters sp =
new SearchParameters()
{
Select = new[] { "metadata_storage_name" },
SearchMode = SearchMode.Any
};
var docs = indexClient.Documents.Search(searchString, sp); // this line no longer works on Live
As it turns out, it had to do with Microsoft's TLS 1.1 and 1.0 decommissioning in the last 2 weeks. I was able to add the following to my code to make it work again (added to my page_load procedure in the default template):
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
However, I'm still working on an issue where the PDF links that are listed in an editor window (using CKEditor extension), will no longer work. I'm assuming this is the same problem, as it works on my local, but not from the Azure web app.

Selenium 2 (webdriver): Taking a Screenshot returns a black image

I am using Selenium 2 (Webdriver), in an ASP.NET website to build a service, where users can enter their URL and gets screenshots of the page, made with different browsers.
My page is hostet on an Windows Server 2008 R2.
Taking Screenshots with FirefoxDriver works perfect.
But when I am using InternetExplorerDriver, I just get an empty black file.
The App is running as Administrator - so there should't be permission issues.
My Code:
// Opening the Browser
var ieCapabilities = DesiredCapabilities.InternetExplorer();
ieCapabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);
var browserIe = new InternetExplorerDriver(ieCapabilities);
browserIe.Navigate().GoToUrl("http://www.google.com");
// Screenshot
var dir = Server.MapPath("/screenshots/");
browserIe.GetScreenshot().SaveAsFile(dir + "Filename.png", ImageFormat.Png);
browserIe.Close();
Any ideas why my file is black?
THANKS!
There's probably nothing wrong with your code. Although, I'm using Java, so I can't tell for sure.
I had the same issue with IE while FF and Chrome worked fine.
This post suggests that starting the Selenium Server via a remote desktop connection could lead to problems.
Some other posts suggest that the screen saver might have something to do with it.
I just tried leaving the remote desktop connection open and it solved the black screenshot issue. Also logging in via VNC seems to work, leading me to the theory that Windows locks the screen after terminating the remote desktop connection while leaving it unlocked if using VNC.
This post suggests that disabling screenshots when the screen is locked is a Windows Security feature.
InternetExplorerDriver mydriver = new InternetExplorerDriver();
mydriver.Navigate().GoToUrl("http://www.google.com/");
Screenshot myScrennShot = ((ITakesScreenshot)iedriver).GetScreenshot();
myScrennShot.SaveAsFile(#"C:\Path\123.png", ImageFormat.Png);
//or
byte[] data = myScrennShot.AsByteArray;
It works for me, probably it does work for you too :-) If it doesn't work I suggest you to separate this code to different service (WindowsService) because in you case this issue maybe connected with application pool restrictions. Anyways, please let me know how is it going.

ITextSharp saying File not found when published to My server

I am using ItextSharp and I am getting a new font for it by doing this
string fontPath = Path.GetFullPath("C:\\BMSApplicationFiles\\Fonts\\FREE3OF9.TTF");
BaseFont barCodeBase = BaseFont.CreateFont(fontPath, BaseFont.CP1252, BaseFont.EMBEDDED);
That file is in that directory on both my dev machine and the server.
When i run this on my dev machine it works fine, when published to my server I get an error saying FREE3OF9.TTF is not found as a file or a resource.
I have double and triple checked that the file is in fact there on my server. My application has full trust on IIS.
and IIS user has full access to this folder. And still I get this error. Very frustrating.
Any ideas??
This code is Not inside the Web Application but inside a DLL class library that the web application is referencing. Do I need to add any more special permissions or something?
Your next step should be to confirm that what you think is happening is happening. If you are allowed to, download and install Process Monitor which will allow you to log activity including which files are being attempted to be accessed and by which user account. Apply filters when monitoring of course, or else you'll end up seeing all the activity on the server...
If that only confirms that the correct file is being attempted to be read by expected user then maybe there's something up with the font. Try replacing the font file temporarily with another standard one (e.g. arial or something) and see what happens. (this is unlikely to help as it works on your dev machine, but might be worth a go)
Most probably you have a security issue.
If you run IIS7 then check that IIS_IUSRS group has an access to the file (open file properties in explorer select Security tab etc).
If you run IIS6 then check that IUSR_MachineName account has an access to the file.
I had a similar error when I tried to get it working with IIS. Within IIS, I had to add he file directory as a virtual drive. That worked for me when I had a similar situation set up. Hopefully it works for you, best of luck

Categories