Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I define in the Settings Tab of a VB.Net class library some user scoped settings. I want to expose these settings to other projects that reference the class library. I chose to do this using a public Module. This works, but it requires exposing each and every setting manually. Is there a better way?

Public Module Settings

    Public Property SomeSetting As Integer
            Return My.Settings.SomeSetting
        End Get
        Set(value As Integer)
            My.Settings.SomeSetting = value
        End Set
    End Property

End Module
share|improve this question
You could expose the Settings module wholesale. – Konrad Rudolph Jan 15 '13 at 10:09
@KonradRudolph Can you elaborate? – Dabblernl Jan 15 '13 at 10:28
Just have a (read-only) property which returns the My.Settings object (no setter required). – Konrad Rudolph Jan 15 '13 at 10:47
If you're going to expose getters and setters, you might as well make the settings public, no? – Mat's Mug Nov 14 '13 at 1:00

I think it's a fairly verbose way of exposing app settings. How about this?

enter image description here

(taken from an answer on this SO question)

This essentially comes down to what @KonradRudolph's comment was saying - the reason you "need" your Settings module is probably because the settings' access modifier is set to Internal, which means it's not accessible to other assemblies.

If you need to expose app settings to other assemblies, you just change that access modifier to Public and you're done.

Doing this:

Public Module Settings
    Public Property AppSettings As Settings
            Return My.Settings
        End Get
    End Property
End Module

Is then totally redundant. Even more so, doing what you've done (exposing each setting individually) becomes more painful to maintain than it needs to be; if the settings are public then you expose the settings class itself and whatever you change is immediately available to client assemblies.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.