System.IO.IOException
System.IO.IOException: Process couldn't access "C:\...\AppData\Local\Packages\38719TimothyJohnson.WinDynamicDesktop_rfarkse4rn21a\LocalState\settings.conf" because it's been used in another process.
I don't actually know if this error causes something serious or not, but still I will report it.
-
Steps to reproduce it: It appears randomly
-
Screenshots (if applicable):

-
Log file (if it exists, see here for how to find it):
System.IO.IOException: O processo não pode acessar o arquivo 'C:\Users\otavi\AppData\Local\Packages\38719TimothyJohnson.WinDynamicDesktop_rfarkse4rn21a\LocalState\settings.conf' porque ele está sendo usado por outro processo. em System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) em System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) em System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) em System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) em System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) em System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost) em System.IO.File.WriteAllText(String path, String contents) em WinDynamicDesktop.JsonConfig.<>c__DisplayClass4_0.<SaveConfig>b__0() em System.Threading.Tasks.Task.InnerInvoke() em System.Threading.Tasks.Task.Execute() --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada --- em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) em WinDynamicDesktop.JsonConfig.<SaveConfig>d__4.MoveNext() --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada --- em System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state) -
Windows version (e.g. 7, 10): Windows 10 Education 1809
-
WinDynamicDesktop version (e.g. 2.0.0): 3.0.0 (UWP)
-
Installation source (e.g. installer, Microsoft Store, portable EXE): Microsoft Store
Something is using some of the files needed for the program to work. Try opening task Manager and closing the process WinDynamicDesktop UPD: or maybe you should run the program as an administrator
P.s. try the GitHub version: https://github.com/t1m0thyj/WinDynamicDesktop/releases/tag/v3.0.0
There shouldn't be a problem with using the Windows Store version or needing admin privileges. There is a bug in the app currently where in some cases the settings file could potentially be locked by WinDynamicDesktop when it tries to save it to disk. This will be fixed in the next version.
I uninstalled the version from Microsoft Store and used the GitHub Setup.exe and the problem seems to be gone now
pfff
I have github version, v3.0.0, got the same exception. Got it after system wake (mby this is the reason).
@t1m0thyj Isn't it the problem with https://github.com/t1m0thyj/WinDynamicDesktop/blob/034f1f8021c6171ac78f0f1da4ca240a572063fd/src/JsonConfig.cs#L61
I believe it should be File.WriteAllTextAsync("settings.conf", newJson));
Now, when Task.Run borrows a new thread from a thread pool, it most probably interferes with some locks made by previous thread. We can reuse existing thread for writing.
Then the function reading the config would become:
public static Task void SaveConfig()
{
string newJson = JsonConvert.SerializeObject(settings);
if (newJson != lastJson)
{
await File.WriteAllTextAsync("settings.conf", newJson));
lastJson = newJson;
}
}
I can create a pull request. If simultaneous read/writes are necessary then we can utilize ReaderWriterLock
@t1m0thyj Isn't it the problem with WinDynamicDesktop/src/JsonConfig.cs
Line 61 in 034f1f8
await Task.Run(() => File.WriteAllText("settings.conf", newJson)); I believe it should be
File.WriteAllTextAsync("settings.conf", newJson));Now, when Task.Run borrows a new thread from a thread pool, it most probably interferes with some locks made by previous thread. We can reuse existing thread for writing.Then the function reading the config would become:
public static Task void SaveConfig() { string newJson = JsonConvert.SerializeObject(settings); if (newJson != lastJson) { await File.WriteAllTextAsync("settings.conf", newJson)); lastJson = newJson; } }I can create a pull request. If simultaneous read/writes are necessary then we can utilize ReaderWriterLock
Create a pull request and t1m0thyj then look at the changes
@FantasiaChan I will make tests over the weekend with my custom version to see if this causes an issue
@MikelThief AFAICT File.WriteAllTextAsync is only available in .NET Core so I can't use it. I believe I've fixed the issue in my latest commit thru making use of SemaphoreSlim.
This should be fixed in version 3.1 which was just released (will take a day or two to show up on the Microsoft Store).