Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Lightswitch 2013桌面应用程序中使用HTML Agility Pack_C#_Visual Studio Lightswitch - Fatal编程技术网

C# 如何在Lightswitch 2013桌面应用程序中使用HTML Agility Pack

C# 如何在Lightswitch 2013桌面应用程序中使用HTML Agility Pack,c#,visual-studio-lightswitch,C#,Visual Studio Lightswitch,我使用Nuget将HTML敏捷包(HAP)添加到我的解决方案中。我的解决方案使用Silverlight 5。有些函数我可以从“using HtmlAgilityPack”调用,但有些函数我不能调用。我需要通过以下代码行获取URL的内容: string Url = "http://google.com.vn"; // this line is okay HtmlWeb web = new HtmlWeb(); // this line is okay HtmlDocument doc = web.

我使用Nuget将HTML敏捷包(HAP)添加到我的解决方案中。我的解决方案使用Silverlight 5。有些函数我可以从“using HtmlAgilityPack”调用,但有些函数我不能调用。我需要通过以下代码行获取URL的内容:

string Url = "http://google.com.vn"; // this line is okay
HtmlWeb web = new HtmlWeb(); // this line is okay
HtmlDocument doc = web.Load(Url); // but this line is highlighted with an error 'Error HtmlAgilityPack.HtmlWeb' does not contain a definition for 'Load' and no extension method 'Load' accepting a first argument of type 'HtmlAgilityPack.HtmlWeb' could be found (are you missing a using directive or an assembly reference?)'
我解决了我的问题

using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using System.Windows;
using Microsoft.LightSwitch.Threading;
using HtmlAgilityPack;

namespace LightSwitchApplication
{
public partial class Table1ItemsListDetail
{
    partial void Method_CanExecute(ref bool result)
    {

        // Write your code here.


    }

    partial void Method_Execute()
    {

            var wc = new HtmlWeb();
            // string url = "http://www.nu.nl/feeds/rss/algemeen.rss";

            wc.LoadAsync("http://google.com");

            wc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(DownloadCompleted);
            //wc.
        //

    }
    void DownloadCompleted(object sender, HtmlDocumentLoadCompleted e)
    {
        if (e.Error == null)
        {
            HtmlDocument doc = e.Document;
            if (doc != null)
            {
                Dispatchers.Main.BeginInvoke(() =>
                {
                    MessageBox.Show(doc.DocumentNode.Element("html").InnerHtml);

                });
            }
        }
    }

}
使用系统;
使用System.Linq;
使用System.IO;
使用System.IO.IsolatedStorage;
使用System.Collections.Generic;
使用Microsoft.LightSwitch;
使用Microsoft.LightSwitch.Framework.Client;
使用Microsoft.LightSwitch.Presentation;
使用Microsoft.LightSwitch.Presentation.Extensions;
使用System.Windows;
使用Microsoft.LightSwitch.Threading;
使用HtmlAgilityPack;
名称空间LightSwitch应用程序
{
公共部分类Table1ItemsListDetail
{
部分无效方法可执行(参考bool结果)
{
//在这里编写代码。
}
部分无效方法_Execute()
{
var wc=新的HtmlWeb();
//字符串url=”http://www.nu.nl/feeds/rss/algemeen.rss";
wc.LoadAsync(“http://google.com");
wc.LoadCompleted+=新的事件处理程序(DownloadCompleted);
//厕所。
//
}
void下载已完成(对象发送者,HTMLDocumentLoade已完成)
{
如果(e.Error==null)
{
HtmlDocument doc=电子文档;
如果(doc!=null)
{
Dispatchers.Main.BeginInvoke(()=>
{
Show(doc.DocumentNode.Element(“html”).InnerHtml);
});
}
}
}
}

}

尝试
LoadAsync()
LoadCompleted
。LoadAsync没有参数LoadCompleted。我试过了