问题
I'm trying to use the Html Agility Pack with a MonoTouch application, but cannot find a version that will work with it.
I downloaded the latest binaries from CodePlex and I've tried building with every DLL it contains. None will compile when the target is the iPhone.
Adding the .NET 20 library will allow it to compile to the iPhone Simulator, but when switching to the iPhone I get the error:
Error MT2002: Can not resolve reference: System.Diagnostics.TraceListener (MT2002) (MFLPlatinum12)
It seems like others are using HtmlAgilityPack with MonoTouch projects, so any thoughts as to what I'm missing?
回答1:
Are you compiling from source or using the DLL directly?
You will need to make a new MonoTouch library project and add all the files for it to work.
Using a DLL directly likely won't work, since it was not compiled for MonoTouch.
回答2:
You have to compile it from code Download the source
go into
\htmlagilitypack-99964\Branches\1.4.0\HtmlAgilityPack
Edit the csproj
change to
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
Save and load
Fix errors
Trace -> Debug
Remove block
if (!SecurityManager.IsGranted(new DnsPermission(PermissionState.Unrestricted)))
{
//do something.... not at full trust
try
{
RegistryKey reg = Registry.ClassesRoot;
reg = reg.OpenSubKey(extension, false);
if (reg != null) contentType = (string)reg.GetValue("", def);
}
catch (Exception)
{
contentType = def;
}
}
Remove block
if (SecurityManager.IsGranted(new RegistryPermission(PermissionState.Unrestricted)))
{
try
{
RegistryKey reg = Registry.ClassesRoot;
reg = reg.OpenSubKey(@"MIME\Database\Content Type\" + contentType, false);
if (reg != null) ext = (string)reg.GetValue("Extension", def);
}
catch (Exception)
{
ext = def;
}
}
Use the dll
in the bin/debug
folder
来源:https://stackoverflow.com/questions/12018240/using-htmlagilitypack-with-monotouch-app-gives-reference-error