简体   繁体   中英

ContentIndexer is not working on Windows 10 Creators Update

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM