none
BingSearchContainer

    Question

  • Hello All,

    Friends i am trying to connect to BingSearchContainer service reference, but everytime i failed with the following error message.

    The custom tool 'DataServiceClientGenerator' failed. Data service client code-generation failed: Object reference not set to an instance of an object..

     

    I would like to add that, i have a valid windows azure marketplace id to access this service, but i m not simply being able to do. 

    Any help will be appreciated, Thanks...

    Wednesday, August 29, 2012 7:41 AM

Answers

  • Hi,

    Where does this exception was thrown? Would you like to share your code and trace messages?

    I think the code will be like this, please check it (make sure Azure marketplace key is correct):

    var bingContainer = new Bing.BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/Search/"));
    var accountKey = "DefaultKeyFromAccountKeysPage";
    // the next line configures the bingContainer to use your credentials.
    bingContainer.Credentials = new NetworkCredential(accountKey, accountKey);
    // now we can build the query
    var imageQuery = bingContainer.Web("xbox", null, null, null, null, null);
    try
    {
        var imageResults = imageQuery.Execute();
        foreach (var result in imageResults)
        {
            txtResults.Text += result.Title;
        }
    }
    catch (Exception ex)
    {
        throw;
    }

    Hope this helps.

    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    • Marked as answer by Girish Attri Monday, September 03, 2012 3:22 PM
    Thursday, August 30, 2012 3:52 AM
    Moderator
  • Are you using Lightswitch?

    The Add New Data Source feature is not supported for Web API resources and you need to use BingSearchContainer class instead.

    Thanks,

    Max

    • Marked as answer by Girish Attri Monday, September 03, 2012 3:22 PM
    Sunday, September 02, 2012 7:06 AM
    Owner

All replies

  • Hi,

    Where does this exception was thrown? Would you like to share your code and trace messages?

    I think the code will be like this, please check it (make sure Azure marketplace key is correct):

    var bingContainer = new Bing.BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/Search/"));
    var accountKey = "DefaultKeyFromAccountKeysPage";
    // the next line configures the bingContainer to use your credentials.
    bingContainer.Credentials = new NetworkCredential(accountKey, accountKey);
    // now we can build the query
    var imageQuery = bingContainer.Web("xbox", null, null, null, null, null);
    try
    {
        var imageResults = imageQuery.Execute();
        foreach (var result in imageResults)
        {
            txtResults.Text += result.Title;
        }
    }
    catch (Exception ex)
    {
        throw;
    }

    Hope this helps.

    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    • Marked as answer by Girish Attri Monday, September 03, 2012 3:22 PM
    Thursday, August 30, 2012 3:52 AM
    Moderator
  • Thanks for Reply,

    Actually the exception has been thrown by the CLR i guess, because i was trying to connect to BingSearchContainer from Data->Add new Data Source->Service->www.????./v1->go, and then selecting the webservice directly from there. But as soon as i clicked on the finish button, i met with the same exception every time.


    Girish Kumar Attri

    Thursday, August 30, 2012 6:06 AM
  • Are you using Lightswitch?

    The Add New Data Source feature is not supported for Web API resources and you need to use BingSearchContainer class instead.

    Thanks,

    Max

    • Marked as answer by Girish Attri Monday, September 03, 2012 3:22 PM
    Sunday, September 02, 2012 7:06 AM
    Owner
  • Thank u both Max and Arwind, my query has been resolved. Thanks for support.

    Girish Kumar Attri

    Monday, September 03, 2012 3:21 PM
  • Hey Girish,

                    How did you solve this problem? Please let me know. I am having same issues since last week.

    Wednesday, June 26, 2013 8:12 PM