|
Rank: Newbie Groups: Member
Joined: 5/1/2012 Posts: 9
|
Hi,
My company has purchased a license for the EO.PDF converter product. We have successfully implemented the product in our dev and one of our test environments, however we are getting the following issue on one of our formal test servers:
Could not load type 'EO.Pdf.Internal.ah' from assembly 'EO.Pdf, Version=3.0.120.2, Culture=neutral, PublicKeyToken=e92353a6bf73fffc'.
This is the first time I have seen this. I tried changing the permissions/security on the dll to match those on the other environments but it is still failing. Can you please tell me what the problem might be?
Thanks,
Iman Mayes
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Can you post the related code and the full call stack of this error message?
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 5/1/2012 Posts: 9
|
Sure,
Here is the stack trace:
[TypeLoadException: Could not load type 'EO.Pdf.Internal.ah' from assembly 'EO.Pdf, Version=3.0.120.2, Culture=neutral, PublicKeyToken=e92353a6bf73fffc'.] GTMWeb.Controllers.DynamicFormsController.TripReportDocument() +117 lambda_method(ExecutionScope , ControllerBase , Object[] ) +40 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24 System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +53 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +258 System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +20 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +195 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +316 System.Web.Mvc.Controller.ExecuteCore() +104 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +36 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34 System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21 System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +53 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +43 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +274 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +157
Here is the code:
/// <summary> /// Action to retrieve PDF version of Dynamic Trip Report /// </summary> /// <returns></returns> public ActionResult TripReportDocument() { int? siteMVSId = int.Parse(getRequestInfo("siteMVSID"));
string strFooter = string.Empty; string allHTML = DynamicFormProvider.GetTripReportAll((int)siteMVSId, true, out strFooter); HtmlDocument allDoc = new HtmlDocument(); allDoc.LoadHtml(allHTML);
//INPUT TYPE=text nodes var textNodes = allDoc.DocumentNode.Descendants("input").Where(f => f.Attributes["type"].Value == "text"); foreach (var item in textNodes.ToList()) { if (item.Attributes["class"] != null && item.Attributes["class"].Value == "date-pick") { var newNodeStr = "<div class='date-pick'>" + item.Attributes["value"].Value + "</div>"; var newNode = HtmlNode.CreateNode(newNodeStr); item.ParentNode.ReplaceChild(newNode, item); } else { string strClass = (item.Attributes["class"] != null) ? " class='" + item.Attributes["class"].Value + "'" : ""; var newNodeStr = "<div" + strClass + ">" + item.Attributes["value"].Value + "</div>"; var newNode = HtmlNode.CreateNode(newNodeStr); item.ParentNode.ReplaceChild(newNode, item); } }
//TEXTAREA nodes textNodes = allDoc.DocumentNode.Descendants("textarea"); foreach (var item in textNodes.ToList()) { var newNodeStr = "<div class='MvcDynamicTextBlock'>" + DynamicFormProvider.parsetext(item.InnerText, false) + "</div>"; var newNode = HtmlNode.CreateNode(newNodeStr); item.ParentNode.ReplaceChild(newNode, item); }
allHTML = allDoc.DocumentNode.WriteTo(); allDoc = null;
PDFConverter pdfConv = new PDFConverter(); pdfConv.SetFooterText = strFooter; pdfConv.ConvertHtmlString(allHTML);
return File(pdfConv.GetPdfDocument, "binary/octet-stream", "Trip Report.pdf"); }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Drawing; using System.IO; using EO.Pdf;
namespace GTMWeb.Models { public class PDFConverter { #region Private Methods /// <summary> /// Add the header to the PDF document /// </summary> private void AddHeader() { //HtmlToPdf.Options.HeaderHtmlFormat = "<div style='float: right; clear: left; padding-bottom: 3px;'><img src='" + AppDomain.CurrentDomain.BaseDirectory + "!Images\\icon_logo.png'/></div>"; HtmlToPdf.Options.HeaderHtmlFormat = "<img align='right' src='" + AppDomain.CurrentDomain.BaseDirectory + "!Images\\icon_logo.png'/>"; }
/// <summary> /// Add the footer to the PDF document /// </summary> private void AddFooter() { HtmlToPdf.Options.FooterHtmlFormat = _footerText; }
#endregion
#region Private Variables //private PdfConverter _pdfConverter = null; private byte[] _pdfDocumentBytes = null; private PdfDocument _pdfDocument = null; private string _footerText = FOOTER_STRING; #endregion
#region Private Constants private const string FOOTER_STRING = ""; private const string MAPPING_PAGE_ORIENTATION_LANDSCAPE = "PAGE_ORIENTATION_LANDSCAPE"; #endregion
#region Public Properties public string SetFooterText { set { _footerText = value; } } #endregion
#region Public Methods /// <summary> /// Instantiate instance of PDFConverter /// </summary> public PDFConverter() {
EO.Pdf.Runtime.AddLicense("xxxxxx");
HtmlToPdf.Options.PageSize = new SizeF(8.5f, 11f);
HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.None; HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None;
HtmlToPdf.Options.NoScript = false; HtmlToPdf.Options.AllowLocalAccess = true;
HtmlToPdf.Options.OutputArea = new RectangleF(0.25f, 1f, 8f, 9.5f);
}
/// <summary> /// Convert HTML string to PDF /// </summary> /// <param name="htmlString">HTML string</param> public void ConvertHtmlString(string htmlString) { AddHeader(); AddFooter(); _pdfDocument = new PdfDocument();
HtmlToPdfResult result; result = HtmlToPdf.ConvertHtml(htmlString, _pdfDocument);
MemoryStream memStream = new MemoryStream(); try { _pdfDocument.Save(memStream); _pdfDocumentBytes = memStream.ToArray(); } finally { memStream.Close(); _pdfDocument = null; } }
/// <summary> /// Return the PDF document as an array of bytes /// </summary> public byte[] GetPdfDocument { get { return _pdfDocumentBytes; } } #endregion
} }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Your code looks fine and this might be related to permissions. As a test, you can try to set your IIS to run under administrator and see if it resolves the problem. We can then go from there. EO.Pdf does not need administrator privileges to function, however it requires full trust permissions.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/1/2012 Posts: 9
|
Hi,
I noticed that IIS was configured to run under Network Service on the server that works, and under a special account on the server that does not work. I changed IIS on the server that has the problem to run under Network Service and I still get the error. Was this what you were talking about? Let me know if there is something else I can try.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Yes. It can be related to that. Also I do not know why the stack trace does not include any of our code. Supposedly it should show where the exception is thrown from our code unless it's a JIT linking error. You can try two things:
1. Move the code that calls us into a separate function and see if you get a different stack trace; 2. Do not call ConvertHtml. Simply "touch" the DLL by calling some insignificant code, such as AddLicense, or just setting a HtmlToPdf.Options member and see if that fails;
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/1/2012 Posts: 9
|
Hi,
I commented out the ConvertHtml call and I don't get an error. I simply set one of the options. Want me to try something else?
Iman
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
In that case you will have to get the full stack trace first (the stack trace you posted does not show any of our code). We need to see the full stack trace in order to decide what the root cause can be.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 5/1/2012 Posts: 9
|
I have tried moving code around to get a stack trace, but it's not working. Is it possible to get a .pdb file for the EVO.Pdf.dll?
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
I don't think you need our PDF file to get our stack trace. The stack trace should always show our code if the exception is from our code. When it doesn't show our code, it's either because the exception does not originate from our code, or the original exception has been caught and eaten by your code, where you can re-throw a new exception with your own stack trace.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 5/1/2012 Posts: 9
|
Hi,
I created a test page in our application that does a very simple conversion and have a better stack trace. Here is the trace:
Could not load type 'EO.Pdf.Internal.ah' from assembly 'EO.Pdf, Version=3.0.120.2, Culture=neutral, PublicKeyToken=e92353a6bf73fffc'. 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.TypeLoadException: Could not load type 'EO.Pdf.Internal.ah' from assembly 'EO.Pdf, Version=3.0.120.2, Culture=neutral, PublicKeyToken=e92353a6bf73fffc'.
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:
[TypeLoadException: Could not load type 'EO.Pdf.Internal.ah' from assembly 'EO.Pdf, Version=3.0.120.2, Culture=neutral, PublicKeyToken=e92353a6bf73fffc'.] EO.Pdf.Internal.ee.b() +114 EO.Pdf.PdfDocument.a() +147 EO.Pdf.PdfDocument.Save(Stream stream) +15 EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream, HtmlToPdfOptions options) +60 EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream) +7 GTMWeb.testiman.Button1_Click(Object sender, EventArgs e) in C:\Users\mayesi\TFSPROJECTS\ICOTrial\Branches\Trunk\GTMWebUI\testiman.aspx.cs:52 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +107 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +111 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3417
Here is the code, just in case:
protected void Button1_Click(object sender, EventArgs e) {
HttpResponse response = HttpContext.Current.Response; response.Clear(); response.ClearHeaders(); response.ContentType = "application/pdf";
[REMOVED BY ADMIN]
HtmlToPdf.Options.PageSize = new SizeF(8.5f, 11f);
HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.None; HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None;
HtmlToPdf.Options.NoScript = false; HtmlToPdf.Options.AllowLocalAccess = true;
HtmlToPdf.Options.OutputArea = new RectangleF(0.25f, 1f, 8f, 9.5f);
byte[] _pdfDocumentBytes = null; PdfDocument _pdfDocument = null;
_pdfDocument = new PdfDocument();
HtmlToPdfResult result; result = HtmlToPdf.ConvertHtml("<html><body>Test</body></html>", response.OutputStream);
response.End();
}
|
|
Rank: Newbie Groups: Member
Joined: 5/1/2012 Posts: 9
|
Thank you for removing key! I was just going back in to edit it out. Sorry about that.
|
|