Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screen saver application doesn't read App.Config

I've written a screen saver in C# but whenever I run it on preview mode or let it kick in, it throws an exception. When I double click it in Windows\System32 it runs fine. With the Visual studio debugger I sussed out that it doesn't read the .config file of the application, which is also in Windows\System32.

I think that when rundll32.exe executes the screen saver, the app.config file is being omitted. Is there a way to force it to load?

Thanks

like image 353
Michael Avatar asked Jul 25 '26 00:07

Michael


2 Answers

Thanks to those who recommended SysInternals' Process Monitor. Using that, I saw that it's looking for an 8-letter version of the config filename. It's the first six letters of the SCR file then ~1.scr, because that's the name of the process. All I have to do is rename the file or, rather keep 2 versions of it as I don't want to change the name of the scr file.

like image 183
Michael Avatar answered Jul 27 '26 14:07

Michael


As far as I remember from my previous experience, screen savers run with its "current directory" set to %userprofile%. You may check if it is true or not by temporarily placing your config file into that directory. And if it happens to be true then you have to add code to read your config from the directory in which your screen saver sits, not from its current directory.

like image 29
Igor Korkhov Avatar answered Jul 27 '26 12:07

Igor Korkhov