What could cause EvoPDF "unable to render html" exception when deployed to Azure Website - azure

Using EvoPDF for a .Net web application works locally, however once deployed to a Microsoft Azure website it throws a generic exception: "unable to render html".
Stack trace:
[Exception: Could not render the HTML string.]
EvoPdf.HtmlToImageConverter.ᜀ(String A_0, String A_1, String A_2, ᜴& A_3, Hashtable& A_4) +2129
EvoPdf.HtmlToPdfConverter.ᜀ(String A_0, String A_1, String A_2, String A_3, Boolean A_4) +8369
EvoPdf.HtmlToPdfConverter.ᜀ(Stream A_0, String A_1, String A_2, String A_3, String A_4, Boolean A_5) +58
EvoPdf.HtmlToPdfConverter.ᜁ(String A_0, String A_1, String A_2, String A_3, Boolean A_4) +126
EvoPdf.HtmlToPdfConverter.ConvertHtml(String htmlString, String baseUrl, String internalLinksBaseUrl) +33
EvoPdf.HtmlToPdfConverter.ConvertHtml(String htmlString, String baseUrl) +12
td.Printing.Labels.Print.WithEvoPdf(HttpContext httpContext, Action`1 htmlPageRenderer, String outputFileName, Label labelFormat) in C:\...\Evo PDF Print Labels.vb:54
td.OL3016WR.Render(HtmlTextWriter writer) in C:\...\OL3016WR.aspx.vb:166
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +80
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8921

You've hit an Azure App Service sandbox runtime exectution limitation.
From https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks:
Unsupported frameworks
Here is a list of frameworks and scenarios that have been found to be not be usable due to one or more of the restrictions above. It's conceivable that some will be supported in the future as the sandbox evolves.
PDF generators failing due to restriction mentioned above:
EVOPDF
Rotativa
wkhtmltopdf
Syncfusion
Siberix
NReco (uses wkhtmltopdf)
Spire.PDF
Other scenarios:
PhantomJS/Selenium: tries to connect to local address, and also uses GDI+.
As you already mentioned this works fine in a Web/Worker Role (Cloud Services).
Service Fabric or IaaS VM are other options.

EvoPdf has a solution for Azure Websites. Check the http://www.evopdf.com/azure-html-to-pdf-converter.aspx page for more details.

Found the general cause. Something about EvoPDF is not compatible with Azure websites. In a cloud services web role it works OK.

I dissed Debenu unjustly. Ended up I was having problem with kernel32 LoadLibrary on the azure server. On my local machine it would take a relative path and find the dll. On azure I had to give it full path and it ran fine. Did not try the gdi+ renderer but 2, cairo worked fine.
To be compliant and provide an answer make sure you send a full path to loadLibrary and choose renderer 2. All good.

Related

What is "AppOffline" which prevents my bot application from getting published to the IIS web server?

Just created an application with the Bot Framework, from the template downloaded here: http://aka.ms/bf-bc-vstemplate.
It works well in the testing Emulator. But when publishing to the IIS server, I got this error:
Error Web deployment task failed. ((5/6/2016 3:03:54 PM) An error occurred when the request was processed on the remote computer.)
(5/6/2016 3:03:54 PM) An error occurred when the request was processed on the remote computer.
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
at Microsoft.Web.Deployment.Base64EncodingHelper.DeserializeHelper(BinaryFormatter formatter, Byte[] buffer)
at Microsoft.Web.Deployment.Base64EncodingHelper.Deserialize(String str, Exception& handledException)
at Microsoft.Web.Deployment.SerializationHelper.Deserialize(String str)
at Microsoft.Web.Deployment.DeploymentAgentWorkerRequest.GetTraceMessage(String[] additionalMessage)
at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentWorkerRequest workerRequest)
at Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData asyncData)
at Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData asyncData)
at Microsoft.Web.Deployment.DeploymentAgent.BeginProcessRequest(DeploymentAgentWorkerRequest workerRequest, AsyncCallback callback, Object extraData)
Unrecognized rule 'AppOffline'. ParkingBot 0
What is the AppOffline error?
I worked around it by doing the following:
locate the .pubxml file for your deployment
toggle EnableMSDeployAppOffline True to
False.
You may need this feature, so it might not be an option. However my application doesn't have this requirement.
Make sure you have the latest version of IIS Web Deploy installed on your server. I was getting this error.
I needed to install Web Deploy 3.6 on our server fixed it.
Check to see if you have a file named app_offline.htm in your deployment folder. That file is for when you're deploying and want to prevent logins on the site until you're done. That file might not have been deleted after deployment.
To add on to jbtule's answer (https://stackoverflow.com/a/49635669/7733418), you might also need to DOWNGRADE to version 3.6. I had Web Deploy 4 installed and was getting the "Unrecognized rule 'AppOffline'" error, but after uninstalling version 4 and installing version 3.6, deployment with <EnableMSDeployAppOffline>True</EnableMSDeployAppOffline>
worked immediately.

Azure HTTPS Endpoint Local Debug Crash w/ "Error Attaching the Debugger"

I'm on Windows 7 Enterprise, Azure SDK 2.0, Azure Web Role Project in VS2012.
As soon as I add an https endpoint in the endpoints section of my Azure Cloud Project properties, I immediately get the following error:
There was an error attaching the debugger to the role instance. Unable to attach. The object invoked has disconnected from its clients.
As soon as i remove the https endpoint, or change the enpoint type to http, everything works. I have also tried running https on ports greater than 1000+, still no good.
It deploys to live fine, and the certificates are obviously then all good.
Any ideas?
Edit
My IISConfigurator.log looks like so:
IISConfigurator Information: 0 : [00000908:00000005, 2013/08/02 23:16:52.448, INFO ] Adding binding 127.255.0.0:82: to site deployment20(284).Widget.AzureProjV2.Widget.Web_IN_0_Web
IISConfigurator Information: 0 : [00000908:00000005, 2013/08/02 23:16:52.448, INFO ] Adding binding 127.255.0.0:446: to site deployment20(284).Widget.AzureProjV2.Widget.Web_IN_0_Web
IISConfigurator Information: 0 : [00000908:00000005, 2013/08/02 23:16:53.211, ERROR] Caught exception
IISConfigurator Information: 0 : [00000908:00000005, 2013/08/02 23:16:53.213, ERROR] Exception:System.Runtime.InteropServices.COMException (0x800401F3): Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))
Server stack trace:
at Microsoft.Web.Administration.Interop.IAppHostProperty.get_Value()
at Microsoft.Web.Administration.ConfigurationElement.GetPropertyValue(IAppHostProperty property)
at Microsoft.Web.Administration.Binding.get_CertificateHash()
at Microsoft.Web.Administration.BindingCollection.Add(Binding binding)
at Microsoft.WindowsAzure.ServiceRuntime.IISConfigurator.WasManager.DeploySite(String roleId, WASite roleSite, String appPoolName, String sitePath, String iisLogsRootFolder, String failedRequestLogsRootFolder, List`1 bindings, List`1 protocols, FileManager fileManager, WAAppPool defaultAppPoolSettings, String roleGuid, String& appPoolSid, List`1 appPoolsAdded, String configPath)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.WindowsAzure.ServiceRuntime.IISConfigurator.WasContainer.DeploySite(String roleId, WASite roleSite, String appPoolName, String sitePath, String iisLogsRootFolder, String failedRequestLogsRootFolder, List`1 bindings, List`1 protocols, FileManager fileManager, WAAppPool defaultAppPoolSettings, String roleGuid, String& appPoolSid, List`1 appPoolsAdded, String configPath)
at Microsoft.WindowsAzure.ServiceRuntime.IISConfigurator.IISConfigurator.Deploy(String roleId, WebAppModel webAppModel, String roleRootDirectory, String sitesDestinationRootDirectory, String diagnosticsRootDirectory, String roleGuid, String configPath)
IISConfigurator Information: 0 : [00000908:00000007, 2013/08/02 23:16:57.399, INFO ] Clean operation called over WCF interface with prefix 'deployment20(284)'
In what will now make the 4th time i've fixed an azure "attaching the debugger" error (for all different reasons) with this process, here is how you fix this.
Actually, my experience is proving this is how you fix EVERY "attaching the debugger" error.
Download the latest ver of Azure SDK if you're not latest
Remove your azure proj from your solution
Make an entirely new cloud/azure proj in solution
Copy the settings from your old proj into the new one (but not by copy/pasting the whole cscfg/csdef files-- theres azure-version-specific stuff in there. Only copy specific lines you need.)

Error associating Azure SQL database with Azure website: System.NullReferenceException: Object reference not set to an instance of an object

I am having a strange error with publishing my website to Azure. I published it to the service using VS 2010 but then have run into this error in connecting my database to the website. The login page works, as do most of the pages on the site, even those that rely on the very same database. The page with the issue comes up with the following text:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
MAO.Controllers.ReviewController.Index() +603
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +214
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
System.Web.Mvc.Controller.ExecuteCore() +106
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +48
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
The error occurs within the following section of code:
public ActionResult ShortDateResponse(int reviewId, int questionId, string response) {
if (string.IsNullOrEmpty(response)) {
var answer = repository.GetAnswerByQuestionId(reviewId, questionId);
if (answer != null) {
repository.DeleteAnswerById(answer.Id);
}
} else {
try {
DateTime date = DateTime.ParseExact(response, "MM/yyyy", CultureInfo.InvariantCulture);
repository.ShortDateResponse(reviewId, questionId, date);
} catch (Exception fe) {
throw new ArgumentException("Date format should be MM/yyyy", fe);
}
}
return Json(new {
success = true,
error = "none"
});
}
on this line:
DateTime date = DateTime.ParseExact(response, "MM/yyyy", CultureInfo.InvariantCulture);
As such, it seems to me the code is not responsible.
I have tried uploading the database to Azure multiple different ways, and according to the various Microsoft tutorials, and have reviewed others who have presented very similar questions on SO and other places. At this point I am not sure how to move forward, so I'm asking.
Initially, I used SQL Management Studio 2008R's "Extract Data-Tier Application" and "Import Data-Tier Application" to load the schema for the database, then "Export Data" and "Import Data" to load up the data onto the server. I ensured that the commandtimeout variable was sat to 0 for all tables so nothing would get lost along the way, and sure enough, everything showed up on the Azure database.
When this presented the aforementioned error, I attempted to use the "Generate scripts" to upload the schema, in case there had been some error with my previous process. I then used Export/Import Data to put the data on the website. I received the same error.
This website does work properly on internal servers, an has been deployed successfully elsewhere, but I'd like to migrate to Azure if possible. Also, I have checked the uploaded website linked to local SQL servers and it has worked properly, so the issue lies in the upload of the SQL database to Azure servers.
I am aware that many people with this error have been able to solve it by editing their connection strings within web.config. I have looked into this, and have manually edited my connection string via Filezilla to the format put forth on various websites, to no avail.
I would really appreciate any insights you have, and let me know if you need more details. Thank you!
One thought is that it might be the firewall rule on the SQL Azure instance. In the Windows Azure Management Portal, go to the "Configure" page for that SQL Azure server. Is it set to "Yes" for allow windows azure services?
Can you also post the code for the controller action MAO.Controllers.ReviewController.Index() so we can see where the null reference exception occurs?

CRM 2011 Service Connection Issue With CallerID

I have an application that connects to the CRM 2011 service. When I attach to the service without a CallerID I can grab the data without error. The hitch comes when I add the caller ID to the connection. I receive this error message (might seem familiar):
The server was unable to process the request due to an internal error.
For more information about the error, either turn on
IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute
or from the configuration behavior) on the server in order to send the
exception information back to the client, or turn on tracing as per
the Microsoft .NET Framework 3.0 SDK documentation and inspect the
server trace logs. Server stack trace: at
System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message
reply, MessageFault fault, String action, MessageVersion version,
FaultConverter faultConverter) at
System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime
operation, ProxyRpc& rpc) at
System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation) at
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message) Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at
Microsoft.Xrm.Sdk.IOrganizationService.Retrieve(String entityName,
Guid id, ColumnSet columnSet) at
Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveCore(String
entityName, Guid id, ColumnSet columnSet) at
Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Retrieve(String
entityName, Guid id, ColumnSet columnSet) at
Hanlon.Data.CRM.DataObjectBase.Retrieve(Guid identity) at
Hanlon.Data.CRM.Advisor.Fill(Guid advisor_identity) at
HypotheticalReportCrmSite.HypotheticalReport.AcceptanceWorkFlow()
Does anyone have any ideas on why this is happening or how I can find out what the error is more specifically? The application works on both Test and User Acceptance servers but blows up on Production.
Clearly there are a number of reasons why this may work differently on different servers, some places to start looking would be the setup/installation/permissions on the different servers including CRM, SQL, Active Directory (although I might assume AD would be the same).
Is there any difference in the proxy used for the Prod server compared to that on the Test/UAT systems?
Are all the relevant versions of the .NET framework available on the Prod server?
Are the same assemblies installed in the GAC?
Is SQL more locked down for the Prod server?
Were the CRM installations on the Prod server completed according to the same specifications as the Test and UAT servers? Were they installed by the same party?
Again, these are all just ideas, but it would seem that the differences between the servers would be the place to look and the installations of the key products would be a good place to start, followed perhaps by looking at the .NET framework etc.
Apologies if the answer is quite generic, but as you have found the specific error doesn't appear to have revealed a smoking gun.
I'd be interested to know what you find.

Sharepoint Word Automation Services Exception

I am trying to do a server side doc/docx to pdf conversion using Word Automation Services. I am using the basic sample from MSDN, Link: http://msdn.microsoft.com/en-us/library/ff742315.aspx and encounter an obscure error every time ConversionJob's Start() method is called. Here's the exception;
Source: mscorlib
Message: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
InnerException: System.ServiceModel.FaultException: An error occurred when verifying security for the message.
StackTrace: Server stack trace: at System.ServiceModel.Channels.SecurityChannelFactory1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout) at System.ServiceModel.Channels.SecurityChannelFactory1.SecurityRequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.IdentityModel.Protocols.WSTrust.IWSTrustContract.Issue(Message message) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst) at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForContext(Uri context, Boolean bearerToken, SecurityToken onBehalfOf, SecurityToken actAs, SecurityToken delegateTo) at Microsoft.SharePoint.SPSecurityContext.<>c_DisplayClass7.b_6() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurityContext.GetProcessSecurityTokenForServiceContext() at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForServiceContext(Uri contextUri) at Microsoft.SharePoint.SPChannelFactoryOperations.InternalCreateChannelActingAsLoggedOnUser[TChannel](ChannelFactory1 factory, EndpointAddress address, Uri via) at Microsoft.SharePoint.SPChannelFactoryOperations.CreateChannelActingAsLoggedOnUser[TChannel](ChannelFactory1 factory, EndpointAddress address) at Microsoft.Office.Word.Server.Service.ConfigChannelFactory1.CreateChannel() at Microsoft.Office.Word.Server.Service.WordServiceApplicationProxy.AddJob(Ucid ucid, Nullable1 subscriptionId, SPUserToken userToken, ConversionJobSettings settings, String name) at Microsoft.Office.Word.Server.Conversions.ConversionJob.Start() at VisualWebPartProject1.VisualWebPart1.VisualWebPart1UserControl.Page_Load(Object sender, EventArgs e)
I tried the same code inside one of our sharepoint sites, still got the same error. Trying this inside a Wcf Service has same result. I made a visual web part for this and same error. Changing user accounts or RunWithElevatedPrivileges didn't help either.
Since the sample requires Microsoft.Sharepoint and Microsoft.Office.Word.Server.Conversions namespaces, I have to run this code on some server having sharepoint installed. So IMHO, the time skew issue is not related as the code is ran over the same server where Word Automation Services are present. I expect some configuration problems on the sharepoint server side, but I don’t know what to check.
Let me know if any other details are required, thanks.
Without having more specifics around the code you're running it's hard to say. Take a look at the overall Word Automation Services content in the SDK.
Also, check out the topics under "Configuring Word Automation Services for Development" in the SDK in particular.

Resources