简体   繁体   中英

HtmlAgilityPack exception has been thrown when used in deployed SSIS package

Trying to read from: sqlserverbuilds.blogspot.com/

Using VS 2017 (15.6.4), leveraging C#, with HtmlAgilityPack 1.7.4, deployed to my OS2016 SSIS Server

When these commands run:

var html = @"http://sqlserverbuilds.blogspot.com/";
HtmlWeb web = new HtmlWeb();
var htmlDoc = web.Load(html);

I always get:

Exception has been thrown by the target of an invocation.

I ensured the HTMLAgilityPack.dll was deployed to the GAC correctly and validated such as:

C:\...\gacutil>gacutil -l HtmlAgilityPack
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:

HtmlAgilityPack, Version=1.7.4.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL

Number of items = 1

When testing within VS2017 it runs fine, w/o error or issue (after I registered it to the GAC).

So, this was a huge oversight on my part. Walking through the Log4Net install suggestion for SSIS helped greatly.

It seems that I registered the dll's on the DB Server, but the standalone SSIS server did not have the dll's registered. I suspect it was the SSIS Server side that my problems were coming from.

On a side note, so that I did not need to install anything special to use the "gacutil.exe", I copied from my local computer (which has VS2017 installed) gacutil.exe, gacutil.exe.config, and gacutlrc.dll to a folder on my server. With those 3 files, I was able to register the HtmlAgilityPack.dll without issue. Command executed: gacutil -I HtmlAgilityPack.dll

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM