[Closed] [C#] a .dll with persistent settings?
I am building a project management tool for max, using C# / .NET to create a .dll and loading the assembly via max script. I want to have some project settings (mostly file path strings) that persist across Max sessions. I tried using C# application settings (via Visual Studio), but while the settings persist as the tool is opened and closed within a single Max session, these do not seem to persist across Max sessions. I suppsoe “application settings” were not meant to work as part of a DLL library. Is there another C# approach to this problem?
isn’t this what ini/xml files are for ? usually kept in
getdir #plugcfg
directory
I would use environment variables for this. You can get and set these via maxscript or dotnet.
mxs –
systemTools.getEnvVariable <string>
systemTools.setEnvVariable <string> { <string> | undefined }
dotnet –
(dotnetclass "System.Environment").setEnvironmentVariable "piersMorgan" "Twat" (dotnetclass "System.EnvironmentVariableTarget").machine
(dotnetclass "System.Environment").GetEnvironmentVariable "piersMorgan" (dotnetclass "System.EnvironmentVariableTarget").machine
Thanks for your responses. I went with Environment variables (I wanted this to take palce in C# not mxs.) I found that with SetEnvironmentVariable , the Environment Variable changes are not read corretcly by GetEnvironmentVariable until reboot. Is there a typical way around this?
I ended up using some proxy variables to hold values in my class until the next reboot.
[EDIT]
On Advice of a more experienced Tools coder I opted for Application Settings rather than Environment Variables. http://stackoverflow.com/questions/453161/best-practice-to-save-application-settings-in-a-windows-forms-application