kurdy
kurdy

Reputation: 471

Could not load file or assembly

I want to archive a pdf version of a DESADV, therefore I create a Html page via Biztalk Custom XSLT Mapping from the original XML file and render it via Pechkin.Synchronized to a pdf (wrapper for wkhtmltopdf).

This works like a charm in my Solution, but once I try to deploy the solution to the QA System biztalk keeps nagging that it can not find the Pechkin Library. The Libs are deployed via "gacutil -I", I even build it from source and signed it with our Biztalk signing key and changed the build mode from x86 to "any CPU". I added all the needed dlls to the Helper Class and deployed them also manually but BizTalk is unable to access the lib. Please help me, I am trying for days without making any progress and it makes me mad. I even struggle to debug why it can not load the dll.

I am not so fluent in BizTalk and always thought that DLLs in the GAC are accessible to BizTalk...

I also build a console application, that directly references to the DLL in GAC_MSIL and the application renders the html with the exact code, I wrote in the BizTalk Solutions helper class.

enter image description here

Upvotes: 0

Views: 1563

Answers (1)

kurdy
kurdy

Reputation: 471

even this can not be considered a real answer but it solved the problem somehow.

As already someone mentioned it, the DLL had dependencies onto other libs. This in combination that I was unable to deploy the DLL to the gac and no deeper understanding of the topic I simply chose another lib as this already took to much time. meh.

I choose the shareware https://selectpdf.com/community-edition/, they have a nuget package that simply worked. (i like). The overall render speed is not as good, but in the end it is more important to stay BizTalk compatible with your project I guess.

If someone stumbles upon this:

  1. Create XSL Mapping for your Message XML and map it to some fancy HTML layout (css supported)
  2. Xtract XML from BizTalk Message in Orchestration
  3. Render PDF with a Helper Solution

My code of the helper class:

You need to add the "Microsoft.XLANGs.BaseTypes" reference from References->Add reference->Assemblies->Extensions for it to work.

using System;
using Microsoft.XLANGs.BaseTypes;
using System.IO;

namespace BIS.CLC.DESADV.Helper
{
    public class HtmlHelper
    {
        public string xTractStringFromMessage(XLANGMessage message)
        {
            string retVal = string.Empty;
            try
            {
                using (var reader = new StreamReader(message[0].RetrieveAs(typeof(Stream)) as Stream))
                {
                    retVal = reader.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                Exception logex = new Exception("BIS.CLC.DESADV.Helper.HtmlHelper.xtractStringFromMsg: string extraction failed" + ex.Message.ToString() + ex.InnerException.ToString());
                BIS.Common.Helper.StaticClass.writeEventLog_BizTalk(logex.Message.ToString(), "BisLog");


                throw ex;
            }
            finally
            {
                message.Dispose();
            }
            return retVal;
        }

        public void renderPDFfromHTML(string html, string targetPath)
        {
            try
            {
                //do things
                SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();
                SelectPdf.PdfDocument doc = converter.ConvertHtmlString(html);
                doc.Save(new Uri(targetPath).LocalPath.Replace(".XML", ".PDF"));
                doc.Close();
            }
            catch (Exception ex)
            {
                Exception logex = new Exception("BIS.CLC.DESADV.Helper.HtmlHelper.renderPDFfromHTML: render pdf failed " + ex.Message.ToString() + ex.InnerException.ToString());
                BIS.Common.Helper.StaticClass.writeEventLog_BizTalk(logex.Message.ToString(), "BisLog");

                throw ex;
            }
        }
    }
}

Upvotes: 1

Related Questions