423,688 Members | 1,894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,688 IT Pros & Developers. It's quick & easy.

error message trying the microsoft console application example

P: n/a
Hi there

I wonder if any one has encountered this problem or can suggest what is
wrong. I am trying the a procedure from the msn site but get the following
message:

Error 1 The type or namespace name 'LiveSearch' does not exist in the
namespace 'ConsoleSampleWebSearch' (are you missing an assembly reference?)
C:\Documents and Settings\Compaq\Local Settings\Application Data\Temporary
Projects\ConsoleSampleWebSearch\Program.cs 13 30 ConsoleSampleWebSearch

I thought I had followed their instructions to the letter - but (as a
newcomer) maybe I am making a faux pas.

I tried editing in different variations on a theme for that line (a few
syntax tricks) to no avail.

below is the example as it appears on the msn site:

I would love to hear from anyone who has (or knows how to) overcome this -
hopefully when I get past these initial hurdles I would aspire to being able
to contribute to your newsgroup answers too (more of a "C"/"C++" person so
far!)

To set up the project in Microsoft Visual Studio .NET 2005 1.. Open
Microsoft Visual Studio .NET 2005 and, from the File menu, choose New |
Project. The New Project dialog box appears.

2.. In the Project types pane, choose Visual C# and then choose Windows.

3.. In the Templates pane, choose Console Application.

4.. Type the name of the project, ConsoleSampleWebSearch, in the Name text
box and click OK. Visual Studio creates a new project.

5.. In the Solution Explorer, right-click References and, from the pop-up
menu, select Add Web Reference.

6.. Type the following address in the URL text box:
http://soap.search.msn.com/webservices.asmx?wsdl.

7.. Click Go.

8.. In the Web reference name text box, type LiveSearch and click Add
Reference.

To add the source code to the project
1.. Replace the source code in the file Program.cs with the source code in
the Example section. To do this:

1.. Click Copy Code to place the code in the Windows Clipboard.

2.. Open Program.cs from the Solution Explorer, place your cursor
anywhere in the file, and press Ctrl + A.

3.. Press Ctrl + V to paste the code into the Visual Studio source file,
overwriting the template-generated code.

2.. Search for and replace the text YOUR_APP_ID_GOES_HERE with the AppID
you generated from the Developer Provisioning System.

3.. Press F5 to run the application in Debug mode.

Requirements
a.. Microsoft Visual Studio .NET 2005 or Microsoft Visual C# .NET 2005.

b.. Internet connection.

c.. Application ID. (See Getting Started with the Live Search API for more
information on obtaining an AppID for use with the Live Search Web Service.)

Demonstrates
A basic Web search using the keywords live search and default input
parameters.

Example
Copy Code
//THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
//TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//PARTICULAR PURPOSE.
//
//Copyright (C) 2007 Microsoft Corporation. All rights reserved.

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services.Protocols;
using System.Net;
using ConsoleSampleWebSearch.LiveSearch;

namespace ConsoleSampleWebSearch
{
class Program
{
static void Main(string[] args)
{
/* TIP: To run any of the samples featured in the API Reference,
remove the code in the try...catch
* block and replace it with the code from the example topic you
want to run. */
try
{
MSNSearchService s = new MSNSearchService();
SearchRequest searchRequest = new SearchRequest();
int arraySize = 1;
SourceRequest[] sr = new SourceRequest[arraySize];

sr[0] = new SourceRequest();
sr[0].Source = SourceType.Web;

searchRequest.Query = "live search";
searchRequest.Requests = sr;
// Enter the Application ID, in double quotation marks,
supplied by the
// Developer Provisioning System, as the value of the AppID
on the SearchRequest.
searchRequest.AppID = "YOUR_APP_ID_GOES_HERE";
searchRequest.CultureInfo = "en-US";
SearchResponse searchResponse;

searchResponse = s.Search(searchRequest);

foreach (SourceResponse sourceResponse in
searchResponse.Responses)
{
Result[] sourceResults = sourceResponse.Results;
if (sourceResponse.Total 0)
{
Console.WriteLine(sourceResponse.Source.ToString() +
" - Total Results: " + sourceResponse.Total.ToString());
Console.WriteLine();
}
foreach (Result sourceResult in sourceResults)
{
if ((sourceResult.Title != null) &&
(sourceResult.Title != String.Empty))
Console.WriteLine("Title: " +
sourceResult.Title);
if ((sourceResult.Description != null) &&
(sourceResult.Description != String.Empty))
Console.WriteLine("Description: " +
sourceResult.Description);
if ((sourceResult.Url != null) && (sourceResult.Url
!= String.Empty))
Console.WriteLine("URL: " + sourceResult.Url);
Console.WriteLine("******************************* **********************");
}
}
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (SoapException fault)
{
Console.WriteLine(fault.Detail.InnerText.ToString( ));
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (WebException webx)
{
Console.WriteLine(webx.ToString());
}
/* This is the end of the try...catch block. */
}
}
}

Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.