cancel
Showing results for 
Search instead for 
Did you mean: 

Web scraping with HtmlAgilityPack - Could not load file or assembly "HtmlAgilityPack"

shahariar_k_bhu
Level 5
Hi, I'm trying to get familiar using code blocks and external dll's. Right now, I wish to create a BO which allows me to parse a HTML page, and retrieve all tables I'm able to identify as a collection. To do this, I'm using C# and the library HtmlAgilityPack. Writing code isn't the hard part, but adding the .dll file seems to be. On my BO's Initialise page, I added the path to the .dll file as en external reference. (C:\Users\USERNAME\Desktop\Net20\HtmlAgilityPack.dll) However, I get the following error message when I try to use the library. "Internal : Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'HtmlAgilityPack, Version=1.4.6.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a' or one of its dependencies. The system cannot find the file specified." I looked at the Knowledge Base, and it recommends you to either add the .dll on BP installation directory (which I'm somehow not allowed to), Win/SYSTEM32 directory, or add the folder in the PATH environment variable. I'm somehow not allowed to do the first two methods. Moreover, I've added the folder (C:\Users\USERNAME\Desktop\Net20\) in the PATH environment variable, but I still get the same error message. I have .NET framework installed (4.6.1, 3.5, 3.0, 2.0), so all version of this HtmlAgilityPack should be supported. Net20 version should support .NET Framework 2.0 and 3.5. I've tried almost all of them. I also restart Blue Prism / run it as admin everytime I make changes to the dll file location. Has anyone experienced something similar? How can I resolve the exception?
5 REPLIES 5

Ansar_AhmedAtta
Level 4
can you share the C# code you have written.?

ZBU
Level 2
Hi, put dll where your user can access it, for example shared drive and then symlink(symbolic link) that dll to BP folder

kshitijkumar
Level 3
Hi , Could you please share me this dll ""HtmlAgilityPack"".

AmiBarrett
Level 12
I went down this path once before, and found that an older version of this DLL is baked into the supplied HTML.dll file in the BP install folder. The only way I was able to prove this, was that the version number changed when I renamed the agility pack DLL to be HTML.dll. (I had another underlying issue that I had to fix to resolve that one.) Unfortunately, doing this also removes all of the additional custom code BP added in which is kind of required to run. If you (or someone else) finds another way to get this to work, let us know. As an alternative, you should be able to use native BP functions to save the HTML on the page to text, then split and parse it via code stage as you like. You just need to have a browser active, which the agility pack lets you avoid. Likewise, you could also try leveraging Selinium.

MonishMunot
Level 3
Copy .dll file into "C:\Program Files\Blue Prism Limited\Blue Prism Automate" directory and restart Blue Prism so that library gets loaded.

------------------------------
Monish Munot
------------------------------