C# Portable Settings Provider

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

  1. 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

  2. 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.

  3. 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!

  4. 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.

  5. 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).

  6. 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_.

  7. “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.

  8. 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?

  9. @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.

  10. 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s