问题
I have been using HTMLAgilityPack from within Visual Studio without a single problem. I extracted HtmlAgilityPack to my HD, and added the file HtmlAgilityPack.dll as a reference to my C# application. Again everything is working splendid from within Visual Studio. I then built my solution and attempted to run my application outside of visual studio (as a standalone desktop executable file) and I get the following error when I run my application:
"Unhanded exception has occurred in your application. If you click Continue, the application will .... Could not load file or assembly 'HtmlAgilityPack, Version=1.4.0.0. Culture=neutral.PublicKeyToken=bd319b...' or one of its dependencies. The system cannot find the file specified."
How is is possible that the system can't find the file specified? Visual Studio had no trouble finding it...
I can provide any additional information upon request.
Thank you for any help with this one - Evan
回答1:
I figured this one out. The problem was that I was using an EXPERIMENTAL copy of HtmlAgilityPack. I changed over to the 'full' version HERE and everything works great now!
回答2:
The assembly HtmlAgilityPack.dll is needed for your program to run. At runtime, the CLR will look for it in several palaces. The most convenient ones are:
- GAC
- Local directory (that's where VS finds it when it executes it).
So either make sure HtmlAgilityPack.dll is in the same directory as you EXE, or put it into the GAC (using gacutil.exe).
回答3:
Build the solution not only the project. Select your solution and press ctrl + Shift + B
来源:https://stackoverflow.com/questions/7287892/htmlagilitypack-reference-not-found-only-after-building-my-application