ContentIndexer is not working on Windows 10 Creators Update

200 views Asked by At

I am working on a old Windows 8 application which is using the ContentIndexer from Windows to build an index for a search engine in the app. It was working well until I updated my computer to the last Creators Update. I get an exception when I'm calling the AddAsync function :

var indexer = Windows.Storage.Search.ContentIndexer.GetIndexer();
await indexer.AddAsync(content);

The exception is : Exception from HRESULT: 0x80040DB4

The inner exception is null :(

For information, the exception is only raised when I am deploying my app on a computer with a Creators update. It's still working on Windows 8 and Windows 10 with previous updates.

I tried to create also a blank Windows 10 UWP app to see if the ContentIndexer is working but it failed too.

Do you any idea to fix this problem ?

Thanks

1

There are 1 answers

3
Nico Zhu On

For information, the exception is only raised when I am deploying my app on a computer with a Creators update. It's still working on Windows 8 and Windows 10 with previous updates.

The problem is the Stream property of content is not available. It is strange that if you don't set Stream and StreamContentType propety, it will work! I will report this issue to the related team. Currently one workaround to add content to indexer is that you could add index by using IndexableContent.

public async static Task<string> AddAppContentFilesToIndexedFolder()
{
    var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
    var installDirectory = Windows.ApplicationModel.Package.Current.InstalledLocation;
    var outputString = "Items added to the \"Indexed\" folder:";
    var appContentFolder = await installDirectory.GetFolderAsync("appcontent-ms");
    var indexedFolder = await localFolder.CreateFolderAsync("Indexed", Windows.Storage.CreationCollisionOption.OpenIfExists);
    var files = await appContentFolder.GetFilesAsync();
    foreach (var file in files)
    {
        outputString += "\n" + file.DisplayName + file.FileType;
        await file.CopyAsync(indexedFolder, file.Name, Windows.Storage.NameCollisionOption.ReplaceExisting);
    }
    return outputString;
}

For more you could refer to official code sample and select Add app content files to be indexed scenario.