问题描述
很抱歉打扰你们,但是我已经尝试了两天了.我目前正在尝试按照您在http://www.codeproject.com/KB/cs/BingSearch.aspx上的示例进行操作,因此我无法克服此错误
使用(LiveSearchService服务=新的LiveSearchService())
{
找不到类型或名称空间名称"LiveSearchService"(您是否缺少using指令或程序集引用?)
现在创建| LiveSearchPortTypeClient |的对象这是基本的Endpoint类.
假设这是我做错的地方,因为我确实知道如何创建Endpoint类:
-布赖恩
I''m really sorry to bother you guys but I''ve been trying for two days now. I am currently trying to follow your example at http://www.codeproject.com/KB/cs/BingSearch.aspx and I am cannot go past this error
using (LiveSearchService service = new LiveSearchService())
{
The type or namespace name ''LiveSearchService'' could not be found (are you missing a using directive or an assembly reference?)
now create an object of |LiveSearchPortTypeClient| which is the basic Endpoint class.
Assume this is where I went wrong,because I do know to how to create an Endpoint class:
- Brian
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using WindowsFormsApplication2.BingService;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Replace the following string with the AppId you received from the
// Bing Developer Center.
const string BingMapsKey = "xxxxxx";
private void btnTranslate_Click(object sender, EventArgs e)
{
string strTranslatedText = null;
try
{
TranslatorService.LanguageServiceClient client = new TranslatorService.LanguageServiceClient();
client = new TranslatorService.LanguageServiceClient();
strTranslatedText = client.Translate("xxxxxx", txtTraslateFrom.Text, "es", "en");
txtTranslatedText.Text = strTranslatedText;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
}
public string SearchOutput(string AppId, string query, int offset, int no_of_res)
{
using (LiveSearchService service = new LiveSearchService())
{
try
{
SearchRequest request = new SearchRequest();
request.AppId = AppId;
request.Query = query;
request.Sources = new SourceType[] { SourceType.Web }; //You may specify multiple
request.Version = "2.0";
request.Market = "en-us";
request.Adult = AdultOption.Moderate;
request.AdultSpecified = true;
// request.Web = new WebRequest();
//request.Web.Count = no_of_res;
//request.Web.CountSpecified = true;
//request.Web.Offset = offset;
//SearchResponse response = service.Search(request);
// return GetResponsestring(response);
}
catch (Exception ex)
{
return ex.Message;
}
}
}
}
}
推荐答案
这篇关于尝试进行Bing搜索.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!