We live in a world where everything must be portable, ranging from mobile applications to making an application able to run on Linux, Windows and OS X. Making a C# application to be completely portable across all windows computers is a problem that Microsoft knows about and willingly admits they will not fix. [Mike] from Geek Republic has taken it upon himself to show us how to hack up some code to make your programs portable. This code is a good push forward for people loving the portability of modern applications. He will admit that bugs may exist so be on the lookout and he would probably appreciate the feedback. Looking forward to a fully working provider so that .NET applications can be carried wherever people go!
19 thoughts on “C# Portable Settings Provider”
Leave a Reply
Please be kind and respectful to help make the comments section excellent. (Comment Policy)
I clicked the source link thinking it would be a way to make C# applications portable across Linux and OSX. This is not the case. It’s how to make .net applications portable across different versions of windows.
This is why I stay away from .net and desktop apps in total. I don’t care what O/S you run so long as it has a browser :-D
eek republic!
Just for clarification, it’s really not meant to make .Net apps portable across different versions of Windows (or to port the entire .Net framework to other OSes).
It is meant to allow users to carry their application settings along with the executable, rather than being tied to Microsoft’s user settings architecture, while still remaining compliant with said architecture.
Does anyone else find the phrase “‘portable’ across all versions of Windows” just a little bit sad?
Very nice! It would have been so simple for Microsoft to have done this. Good work Mike @ Geek-Republic!
If your comment is simply “Booooo. Lame. Microsoft iz teh devil.” please keep it to yourself. If, however, you have something constructive to add, please do so.
Regarding the library, that will be going on my .NET tool belt. Thanks!
portable’ across all versions of Windows. : D I just shit myself a little
@tristramoaten
If you want to run C# applications on Linux and OSX you should look into the Mono framework.
I’ve often grumbled that overloading the word “portable” was a bad idea, and the confusion above only reinforces this. This has absolutely nothing to do with software portability, but is about storing the application’s .config file in the same directory as the executable, presumably so you can run the software from writeable removable storage and take the settings around with you rather than have them stored in your user profile.
Given that most applications install in Program Files and won’t be able to write to their own directory (not to mention that most apps would want to maintain different settings per user, and/or store those settings in a roaming profile) I think Microsoft’s implementation is a good one for the general case. I’m not sure why the author rags on Microsoft so much as it’s relatively straightforward to write your own provider if you want to go against the “correct” way to store settings on Windows.
HAD you should put a warning on hilarious posts, now I have to skip a lecture and go home for a change
In summary, when you write a .net app save files in the path of the Executing Assembly or it’ll end up in some weird folder in your user dir
Wow… .net is not even portable between different versions of windoze… Hint: use QT
I was amazed how ‘useless’ settings were stored normally. The executable path, version, instance all are part of the so called evidence that needs to match. No fun when updating versions or debugging.
So then I tried the (non-portable) RegistrySettingsProvider example from MS$, then an improved version by someone else with some tweaks of my own (null & SerializedValue handling).
Names like “Geek Republic” are ridiculous.
http://www.stealth-x.com/articles/why-i-hate-nerds.php
TL;DR: “Geek” is a stereotypical nightmare for hackers.
Where does the link say anything about making a C# apps portable across versions of Windows? C# targets .NET, which indeed _is_ compatible across versions of Windows.
It also has nothing to do with C# except that the hack given uses code “reuse” via copy-and-paste.
Instead, the link gives a way to have a single configuration for multiple apps or instances of an app. Usually, this is _bad_.
“Making a C# application to be completely portable across all windows computers is a problem that Microsoft knows about and willingly admits they will not fix.”
What is your reference? This is _not_ in the given link.
wow, c# isn’t portable between different versions of windows – it’s true ’cause had said so! Seriously, this isn’t a hack, just some sample code. If I was looking for sample code or hints and tips, I’d be reading stackoverflow.com and the like, not had. Doing those coding primers is one thing, but this?
@Jason:
First off, any site which starts off with “subject/hobby ‘x’ was so much easier before I got into it and I am a genius for knowing what I know today” is likely not worth reading. These things do not get easier or more difficult. We can do more simply because we build upon the effort of our predecessors, not because we are more intelligent or exert more effort.
Second, you weaken yourself by feeling offended by such a term. It is best to embrace it so that it has no power and prove the stereotype wrong through action. See “Yankee” used before the American revolution and after (sports teams, etc), the use of “ham” for amateur radio operators, and others.
Well, anybody who creates commercial level .NET applications already have a library for configuration management. This code is not something significant at all. It’s just another config lib.