ASP.NET => Compiler Error Message: CS0246: The type or namespace name 'HtmlAgilityPack'

冷暖自知 提交于 2019-12-11 19:58:21

问题


using HtmlAgilityPack;

// reference it

Produces error: ASP.NET => Compiler Error Message: CS0246: The type or namespace name 'HtmlAgilityPack' ...

HtmlAgilityPack IS referenced in my web site.

Switched from ASP.NET 2.0 to 4.0. After that, got this error. When making a console or windows forms application, all is fine, but ASP.NET build system gives me this error. I have this compile error when using HtmlAgilityPack.

No luck till today fixing this.


回答1:


Had the same problem, my .NET project was targeting .NET Framework 4.0 but HtmlAgilityPack.dll was build with .NET Framework 4.5.

The solution was to reference the HtmlAgilityPack.dll build with .NET Fx 4.0.

The download package for HtmlAgilityPack offers versions for Net20, Net40, Net45 and even WinRT.




回答2:


Please set the Copy Local property to True on the Referenced DLL of HtmlAgilityPack

This will copy the dll to the output directory of your application




回答3:


So it worked before you changed the Framework Version to .Net 4?

If that's the case that sounds more like you also need to upgrade your dll to .Net 4.

Just get the release from Codeplex, in the zip there is a version of the AgilityPack for every Framework Version there is, just get the one for .Net 4 and see if that changes anything.



来源:https://stackoverflow.com/questions/11776161/asp-net-compiler-error-message-cs0246-the-type-or-namespace-name-htmlagili

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!