Hardcoding path to user.config?

Asked by Bartek

Hello,

Is it possible to hardcode a path to user.config file in .net client by altering sources some way? Or maybe not whole path, but last directory name in Local Settings/Application Data or AppData/Local ?
I've tried to figure it out myself but my c# and google knowledge seems to be too weak :(
Right now depending of way of staring client exe file (cron, cmdline, factory menu shortcut, etc) i'm getting different XiboClient.exe_Url_* pathes, so client started from script, cron can't read previously configured settings :(

Question information

Language:
English Edit question
Status:
Solved
For:
Xibo Edit question
Assignee:
No assignee Edit question
Solved by:
Bartek
Solved:
Last query:
Last reply:
Revision history for this message
Alex Harrington (alexharrington) said :
#1

If you configure the scheduled task to run as the user the computer logs on as then it should pick up the right settings?

This email carries a disclaimer, a copy of which may be read at http://learning.longhill.org.uk/disclaimer

Revision history for this message
Bartek (czajka) said :
#2

It was my first shot, but it's not true :(

For example in start.bat file in my two different installations :

start PATCH_TO_EXE

and

PATCH_TO_EXE

producing different XiboClient.exe_Url_RANDOM folders (in same user -> local setting folder) , so its quite unpredictable becouse i don't know what is the base to compute RANDOM part. so I wanted to hardcode RANDOM some way.

Revision history for this message
Alex Harrington (alexharrington) said :
#3

RANDOM isn't random according to the MS Knowledgebase:

http://stackoverflow.com/questions/621265/-net-2-0-application-settings-user-config-file-location

It looks to me like you're running either different versions of the client or versions installed by different MSI package IDs - which will apparently cause that hash to change.

On my machine I get the same options displayed in the client whether I run "PATH_TO_CLIENT.exe options" or start "PATH_TO_CLIENT.exe options" or if I call that from Scheduled Tasks if I set the user that runs as as me.

Alex

Revision history for this message
Alex Harrington (alexharrington) said :
#4

If you mean that RANDOM changes from PC to PC then you're quite correct - that's how Microsoft specify .net applications should store their settings.

If you want to avoid that, then you'd have to write a whole settings management class yourself.

Alex

Revision history for this message
Bartek (czajka) said :
#5

Ok, you're right its not random, i'm updating client by hand from time to time by putting new exe in Program Files instead of playing with msi.
But i'm really getting different hash in some installations with start and no start combinations :) Probably becouse new version somehow read previous versions conf in some context, and generate new in some other when replaced with new binary and started different way at one time. That's the reason why I want to set folder name to fixed value - when using cron i don't need any msi stuff - shortcuts in menu starts points to some cmd scripts, not xibo's exe files.

Thanks for link, i'll try to search answer here :)

Revision history for this message
Alex Harrington (alexharrington) said :
#6

If you need to hard code it then I think you'll have to rewrite the settings management from scratch - that path isn't specified anywhere, it's generated at the .net framework level. I don't think there's a quick fix.

Alex

Revision history for this message
Bartek (czajka) said :
#7

I think that overriding values used to generate SHA1 to some constant value could be possible. I don't need something nice looking here, rather some XiboClient.exe_Url_constantsha1.

Revision history for this message
Alex Harrington (alexharrington) said :
#8

Yes. But that's all done at the .net framework level - so I don't see how you can influence it.

This email carries a disclaimer, a copy of which may be read at http://learning.longhill.org.uk/disclaimer

Revision history for this message
Bartek (czajka) said :
#9

I have no idea right now, let's say that my vc# knowledge is very limited, but i've found some example:

Your provider will need to implement one property and one method whose implementations may not be obvious. The ApplicationName property is an abstract property of SettingsProvider; you should program it to return the following:

public override string ApplicationName
{
    get
    {
        return (System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
    }
    set
    {
        // Do nothing.
    }
}

so mayble return ("someconstant") + overriding something else that ApplicationName could do the trick :)

Revision history for this message
Bartek (czajka) said :
#10

Digged some more and found that there is no way to change path without writing new shiny configuration management, as You said before :( So i'm closing that question.