locked
Under which circumstances does searchSuggestionCollection.appendResultSuggestion throw "Invalid Pointer"?

    Question

  • The 

    searchSuggestionCollection.appendResultSuggestion

    throws an "Invalid Pointer" when called with a null image, which should be legal to do.


    Any ideas what else might cause this? The searchSuggestionCollection object I am operating on is still valid. Other functions can be called in it
    Monday, December 17, 2012 10:58 AM

Answers

  • Hi,

    Please refer to the code as follow:

    // Generate Search Pane suggestion from XML mark up for a single suggestion.
                function addSuggestionFromNode(node, suggestions) {
                    if (node.nodeName !== "Item") {
                        return null;
                    }
    
                    var text, description, url, imageUrl, imageAlt;
    
                    // Obtain suggestion values
                    for (var i = 0; i < node.childNodes.length; i++) {
                        switch (node.childNodes[i].nodeName) {
                            case "Text":
                                text = node.childNodes[i].textContent;
                                break;
                            case "Description":
                                description = node.childNodes[i].textContent;
                                break;
                            case "Url":
                                url = node.childNodes[i].textContent;
                                break;
                            case "Image":
                                if (node.childNodes[i].attributes.getNamedItem("source")) {
                                    imageUrl = node.childNodes[i].attributes.getNamedItem("source").value;
                                }
                                if (node.childNodes[i].attributes.getNamedItem("alt")) {
                                    imageAlt = node.childNodes[i].attributes.getNamedItem("alt").value;
                                }
                                break;
                        }
                    }
    
                    if (!description) {
                        description = "";
                    }
    
                    if (!text || text === "") {
                        // No proper suggestion item exists
                    } else if (!url) {
                        suggestions.appendQuerySuggestion(text);
                    } else {
                        var imageUri;
                        if (imageUrl || imageUrl === "") {
                            // We require an image for result suggestions.
                            imageUri = new Windows.Foundation.Uri(imageUrl);
                        } else {
                            // The following image should not be used in your application for Result Suggestions.  Replace the image with one that is tailored to your content.
                            imageUri = new Windows.Foundation.Uri("ms-appx:///Images/SDK_ResultSuggestionImage.png");
                        }
                        if (imageUri) {
                            var imageSource = Windows.Storage.Streams.RandomAccessStreamReference.createFromUri(imageUri);
                            suggestions.appendResultSuggestion(text, description, url, imageSource, imageAlt);
                        }
                    }
                    return;
                }

    #SearchSuggestionCollection.AppendResultSuggestion | appendResultSuggestion method (Windows)

    http://msdn.microsoft.com/en-US/library/windows/apps/hh700542


    Roy
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    • Edited by Song Tian Tuesday, December 18, 2012 7:39 AM
    • Marked as answer by Song Tian Friday, December 21, 2012 9:59 AM
    Tuesday, December 18, 2012 7:37 AM