This project is read-only.

Switching error

Sep 27, 2015 at 12:16 PM
I reset my windows 10 yesterday, and after reinstalling Wallswitch, I'm getting this error in the log. Not every time, but maybe three out of five times it changes. The error is always the same.
I have checked the folder permissions, and Desktop, System, and User all have full access.
Any thoughts?
[2015-09-27 07:12:25.761] (Info) Switching wallpaper for theme 'Default'
[2015-09-27 07:12:26.589] (Error) 
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
   at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
   at System.Drawing.Image.Save(String filename, ImageFormat format)
   at WallSwitch.SetWallpaper.SaveWallpaperImage(String fileName, Bitmap image, ImageFormat format, ScreenList screens)
[2015-09-27 07:12:26.730] (Info) Next wallpaper switch is in 30 seconds
Sep 27, 2015 at 4:13 PM
This error seems to happen when it can't save the image file. While I haven't seen this happen myself, I was able to reproduce it by setting the wallpaper image file to read-only, which would fail when it attempts to write the next wallpaper over top (I doubt this is exactly your problem, but it may something similar).

Maybe something is up with the existing image files from before your Windows 10 reset. You could try deleting all the .png and .jpg files under c:\users_username_\AppData\Local\WallSwitch, and seeing if it clears up.
Sep 27, 2015 at 4:18 PM
Yup, that's what I thought too, so I uninstalled, and deleted the folder. Still happening.
Is there an ini file where I can maybe change the folder it's saving to? I could direct it to my documents and it could auto create a wallswitch folder there?

Sep 27, 2015 at 4:24 PM
I'm going to change the way it writes the image file to the disk. Stay tuned for an update...
Sep 27, 2015 at 4:24 PM
It's also occasionally throwing this one. I've checked all the handles and can't find anything using it (although I may not be fast enough on the refresh).

[2015-09-27 11:21:33.860] (Error)
System.IO.IOException: The process cannot access the file 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at 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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at WallSwitch.SetWallpaper.LoadBitmapFromFile(String fileName)
at WallSwitch.SetWallpaper.LoadWallpaperImage(String fileName, ScreenList screens)
[2015-09-27 11:21:34.462] (Info) Next wallpaper switch is in 30 seconds

Capture.JPG


Sep 27, 2015 at 4:29 PM
Thanks.
It was fine before I reset Windows. I honestly don't know what changed.
I've even tried a few older versions just to be sure.

Sep 27, 2015 at 4:51 PM
Ok, version 1.3.10 is up now. Hopefully this solves that problem.
Sep 27, 2015 at 5:00 PM
Weird. Here's the full log since upgrading.
Sep 27, 2015 at 5:13 PM
Hmm... I'm not able to see the log.
Sep 27, 2015 at 5:13 PM
It's throwing this now, but I can't see why...

[2015-09-27 12:08:28.140] (Warning) Error when attempting to save image file 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png', will retry 2 more time(s):
System.UnauthorizedAccessException: Access to the path 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at 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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.File.InternalWriteAllBytes(String path, Byte[] bytes, Boolean checkHost)
at System.IO.File.WriteAllBytes(String path, Byte[] bytes)
at WallSwitch.SetWallpaper.WriteImageHardened(String fileName, Image img, ImageFormat format)
Capture.JPG


Sep 27, 2015 at 5:15 PM
Here's a copy.Capture.JPG
[2015-09-27 12:08:27.953] (Error)
System.IO.IOException: The process cannot access the file 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at 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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at WallSwitch.SetWallpaper.LoadBitmapFromFile(String fileName)
at WallSwitch.SetWallpaper.LoadWallpaperImage(String fileName, ScreenList screens)
[2015-09-27 12:08:27.953] (Error)
System.IO.IOException: The process cannot access the file 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at 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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at WallSwitch.SetWallpaper.LoadBitmapFromFile(String fileName)
at WallSwitch.SetWallpaper.LoadWallpaperImage(String fileName, ScreenList screens)
[2015-09-27 12:08:28.140] (Warning) Error when attempting to save image file 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png', will retry 2 more time(s):
System.UnauthorizedAccessException: Access to the path 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at 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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.File.InternalWriteAllBytes(String path, Byte[] bytes, Boolean checkHost)
at System.IO.File.WriteAllBytes(String path, Byte[] bytes)
at WallSwitch.SetWallpaper.WriteImageHardened(String fileName, Image img, ImageFormat format)
[2015-09-27 12:08:29.547] (Debug) Finished switching wallpaper.
[2015-09-27 12:08:29.547] (Info) Next wallpaper switch is in 30 seconds


Sep 27, 2015 at 5:19 PM
That error means it's definitely a permissions problem. Normally your account should have access to write files under your user profile, and I've never seen a case where it hasn't, so this is extra puzzling. With your Windows 10 "reset", was than an upgrade from another version, or a clean install?

You might want to temporarily grant 'full access' to 'everyone' on the folder C:\Users\fresh\AppData\Local\WallSwitch to see if that clears it up.
Sep 27, 2015 at 5:26 PM
Regarding the "The process cannot access the file X because it is being used by another process" error messages, could there be another process locking the files behind the scenes? A virus scanner, perhaps?
Sep 27, 2015 at 5:26 PM
I've been on a proper install since it was offered in July. That's the first access error I've seen.
I've added "Everyone" and given it full access. I'll let you know. I'd really like to know what process is accessing it that it can't be overwritten, but process explorer doesn't show anything...
I'll reboot and get back to you.
Thanks for the help. Sorry to crap on your weekend.

Sep 27, 2015 at 5:34 PM

I usually use avast, but I haven't installed one yet. It is possible that a windows defender or something is using it, but that would just be a default install. Shouldn't be an issue.


Sep 27, 2015 at 5:37 PM
What I can't figure out is that it can run proper for a while, then, just not.
That's why I though maybe I could change the folder or something.

[2015-09-27 12:34:46.602] (Info) Next wallpaper switch is in 30 seconds
[2015-09-27 12:35:03.201] (Debug) Reregistering hotkey [Ctrl + Shift + Q] ID [1].
[2015-09-27 12:35:03.201] (Debug) Successfully reregistered hotkey [Ctrl + Shift + Q] with ID [1].
[2015-09-27 12:35:04.858] (Info) Switching wallpaper for theme 'Default'
[2015-09-27 12:35:04.858] (Debug) Finding next images...
[2015-09-27 12:35:04.858] (Debug) 63228 files found.
[2015-09-27 12:35:05.186] (Debug) Image: D:\Guys\Tumblr\00028\125192059103 - be cool.jpg
[2015-09-27 12:35:05.186] (Debug) Image: D:\Guys\Tumblr\00028\125192059103 - be cool.jpg
[2015-09-27 12:35:05.186] (Debug) Screen Layout:
[2015-09-27 12:35:05.186] (Debug) Screen 0:
[2015-09-27 12:35:05.186] (Debug) Primary: True
[2015-09-27 12:35:05.186] (Debug) Bounds: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:05.186] (Debug) Working Area: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:05.186] (Debug) Screen 1:
[2015-09-27 12:35:05.186] (Debug) Primary: False
[2015-09-27 12:35:05.186] (Debug) Bounds: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:05.186] (Debug) Working Area: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:05.878] (Debug) Finished switching wallpaper.
[2015-09-27 12:35:05.878] (Info) Next wallpaper switch is in 30 seconds
[2015-09-27 12:35:17.051] (Info) Switching wallpaper for theme 'Default'
[2015-09-27 12:35:17.051] (Debug) Finding next images...
[2015-09-27 12:35:17.051] (Debug) 63228 files found.
[2015-09-27 12:35:17.238] (Debug) Image: D:\Guys\Tumblr\00024\117358166844.jpg
[2015-09-27 12:35:17.238] (Debug) Image: D:\Guys\Tumblr\00024\117358166844.jpg
[2015-09-27 12:35:17.238] (Debug) Screen Layout:
[2015-09-27 12:35:17.238] (Debug) Screen 0:
[2015-09-27 12:35:17.238] (Debug) Primary: True
[2015-09-27 12:35:17.238] (Debug) Bounds: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:17.238] (Debug) Working Area: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:17.238] (Debug) Screen 1:
[2015-09-27 12:35:17.238] (Debug) Primary: False
[2015-09-27 12:35:17.238] (Debug) Bounds: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:17.238] (Debug) Working Area: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:18.035] (Debug) Finished switching wallpaper.
[2015-09-27 12:35:18.035] (Info) Next wallpaper switch is in 30 seconds
[2015-09-27 12:35:22.098] (Info) Switching wallpaper for theme 'Default'
[2015-09-27 12:35:22.098] (Debug) Finding next images...
[2015-09-27 12:35:22.098] (Debug) 63228 files found.
[2015-09-27 12:35:22.254] (Debug) Image: D:\Guys\Tumblr\00015\109145746303.jpg
[2015-09-27 12:35:22.254] (Debug) Image: D:\Guys\Tumblr\00015\109145746303.jpg
[2015-09-27 12:35:22.254] (Debug) Screen Layout:
[2015-09-27 12:35:22.254] (Debug) Screen 0:
[2015-09-27 12:35:22.254] (Debug) Primary: True
[2015-09-27 12:35:22.254] (Debug) Bounds: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:22.254] (Debug) Working Area: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:22.254] (Debug) Screen 1:
[2015-09-27 12:35:22.254] (Debug) Primary: False
[2015-09-27 12:35:22.254] (Debug) Bounds: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:22.254] (Debug) Working Area: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:23.035] (Debug) Finished switching wallpaper.
[2015-09-27 12:35:23.035] (Info) Next wallpaper switch is in 30 seconds
[2015-09-27 12:35:29.107] (Info) Switching wallpaper for theme 'Default'
[2015-09-27 12:35:29.107] (Debug) Finding next images...
[2015-09-27 12:35:29.107] (Debug) 63228 files found.
[2015-09-27 12:35:29.232] (Debug) Image: D:\Guys\Tumblr\00002\100609508960_5.jpg
[2015-09-27 12:35:29.232] (Debug) Image: D:\Guys\Tumblr\00002\100609508960_5.jpg
[2015-09-27 12:35:29.232] (Debug) Screen Layout:
[2015-09-27 12:35:29.232] (Debug) Screen 0:
[2015-09-27 12:35:29.232] (Debug) Primary: True
[2015-09-27 12:35:29.232] (Debug) Bounds: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:29.232] (Debug) Working Area: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:29.232] (Debug) Screen 1:
[2015-09-27 12:35:29.232] (Debug) Primary: False
[2015-09-27 12:35:29.232] (Debug) Bounds: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:29.232] (Debug) Working Area: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:35:29.232] (Error)
System.IO.IOException: The process cannot access the file 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at 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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at WallSwitch.SetWallpaper.LoadBitmapFromFile(String fileName)
at WallSwitch.SetWallpaper.LoadWallpaperImage(String fileName, ScreenList screens)
[2015-09-27 12:35:29.232] (Error)
System.IO.IOException: The process cannot access the file 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at 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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at WallSwitch.SetWallpaper.LoadBitmapFromFile(String fileName)
at WallSwitch.SetWallpaper.LoadWallpaperImage(String fileName, ScreenList screens)
[2015-09-27 12:35:29.732] (Debug) Finished switching wallpaper.
[2015-09-27 12:35:29.747] (Info) Next wallpaper switch is in 30 seconds


Sep 27, 2015 at 5:54 PM
Looks like the problem's in the image loading now. I've hardened that code now too. Rather than doing up a new version for each attempted fix, could you paste the file below into your C:\Program Files (x86)\WallSwitch folder?

https://dl.dropboxusercontent.com/u/6512288/WallSwitch.exe
Sep 27, 2015 at 5:58 PM
Sure.
I'll clear the log and let you know if it happens again.


Sep 27, 2015 at 6:11 PM
It's still throwing errors, but it's eventually busting through them... It hasn't reset itself to black yet and there's been two dozen changes.
Whatever you changed seems to have worked. I've only been using it on Collage Default, but I assume the system read/write won't change with he display settings.
I'll let you know if anything else happens.
Thanks for your help!

This is what it's tossing now:
[2015-09-27 12:59:14.767] (Info) Next wallpaper switch is in 30 seconds
[2015-09-27 12:59:44.786] (Info) Switching wallpaper for theme 'Default'
[2015-09-27 12:59:44.786] (Debug) Finding next images...
[2015-09-27 12:59:44.787] (Debug) 63246 files found.
[2015-09-27 12:59:44.953] (Debug) Image: D:\Guys\Tumblr\00041\37254767976.jpg
[2015-09-27 12:59:44.953] (Debug) Image: D:\Guys\Tumblr\00041\37254767976.jpg
[2015-09-27 12:59:44.953] (Debug) Screen Layout:
[2015-09-27 12:59:44.953] (Debug) Screen 0:
[2015-09-27 12:59:44.953] (Debug) Primary: True
[2015-09-27 12:59:44.953] (Debug) Bounds: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:59:44.953] (Debug) Working Area: {X=0,Y=0,Width=1680,Height=1050}
[2015-09-27 12:59:44.953] (Debug) Screen 1:
[2015-09-27 12:59:44.953] (Debug) Primary: False
[2015-09-27 12:59:44.953] (Debug) Bounds: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:59:44.953] (Debug) Working Area: {X=1680,Y=0,Width=1680,Height=1050}
[2015-09-27 12:59:45.409] (Warning) Error when attempting to save image file 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png', will retry 2 more time(s):
System.UnauthorizedAccessException: Access to the path 'C:\Users\fresh\AppData\Local\WallSwitch\395a48f1-c4bf-4250-ac32-a65a25ac327c_display.png' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at 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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.File.InternalWriteAllBytes(String path, Byte[] bytes, Boolean checkHost)
at System.IO.File.WriteAllBytes(String path, Byte[] bytes)
at WallSwitch.SetWallpaper.WriteImageHardened(String fileName, Image img, ImageFormat format)
[2015-09-27 12:59:46.893] (Debug) Finished switching wallpaper.

Sep 27, 2015 at 6:30 PM
In collage mode it does need to read the previous image, whereas in full-screen mode it doesn't do that because the previous wallpapers are not displayed. A while ago I did encounter troubles with Microsoft's image library placing locks on image files for longer than it should, but I thought I had that sorted out by loading the file content into memory first. My latest fix completely divorced the image library from the file stream, so it shouldn't be doing that anymore, but the fact that it still had to do a retry to write the file is disconcerting. Something's still locking that file... it's something I'll ponder for a while.
Sep 27, 2015 at 6:37 PM
It seems to be fine now from a desktop view.
In the log it's still trying two more times before it lands, but it is eventually landing.
From what I can see, nobody would notice an issue unless they checked the log.

Considering I reset my PC, I wonder if there was a change to a library or something between first release and whatever version I have now.
It does check for updates during the install process, but it doesn't tell you what's being updated. Basically, it only says "It's for your own good"..
:-)
Thanks again.