Exception when reading text from the file using Fi

2020-08-16 03:04发布

问题:

I am getting the following exception when attempting to read a locl text file using

var text = await FileIO.ReadTextAsync(file);

The handle with which this oplock was associated has been closed. The oplock is now broken. (Exception from HRESULT: 0x80070323)

This happens in one of the regression unit tests, it also happens from time to time in the app. App is XAML + C#

Any ideas what might be causing it?!

回答1:

I was having the same problem, that ocurred by concurrence threading. I was trying to acess the same file in two places at the same time and didn't realize it.

Try to verify your code looking for some another acess to the same file and verify if you are closing after read it, and don't forget to call "await" or use a lock in every file reading. I think it may solve your issue.