Simple question on Properties.Settings


D

Dom

It seems I can't look at the Properties.Settings.Default.xxxx value in
the immediate window while I'm in debug mode. If I try, I get the
message: "'System.Windows.Forms.PropertyStore' does not contain a
definition for 'Settings'"

I can still Debug.Print the value in my code.

What gives?
 
Ad

Advertisements

P

Peter Duniho

Dom said:
It seems I can't look at the Properties.Settings.Default.xxxx value in
the immediate window while I'm in debug mode. If I try, I get the
message: "'System.Windows.Forms.PropertyStore' does not contain a
definition for 'Settings'"

Sounds like a namespace issue. The actual application
Properties.Settings.Default.xxxx values are not in
System.Windows.Forms.PropertyStore, so you can see from the error that
the immediate window is trying to use a different Properties than the
one you need.

The Settings class in which the values exist is actually in Properties
namespace within your own application's namespace.

So, if your program's namespace is MyProgram, you should be able to show
the settings via MyProgram.Properties.Settings.Default.xxxx (where xxxx
is whatever setting you're looking for, of course).

Pete
 
D

Dom

Sounds like a namespace issue. The actual application
Properties.Settings.Default.xxxx values are not in
System.Windows.Forms.PropertyStore, so you can see from the error that
the immediate window is trying to use a different Properties than the
one you need.

The Settings class in which the values exist is actually in Properties
namespace within your own application's namespace.

So, if your program's namespace is MyProgram, you should be able to show
the settings via MyProgram.Properties.Settings.Default.xxxx (where xxxx
is whatever setting you're looking for, of course).

Pete

That did it. Thanks. Any idea why the immediate window is using the
wrong ns?
 
D

Dom

Sounds like a namespace issue. The actual application
Properties.Settings.Default.xxxx values are not in
System.Windows.Forms.PropertyStore, so you can see from the error that
the immediate window is trying to use a different Properties than the
one you need.

The Settings class in which the values exist is actually in Properties
namespace within your own application's namespace.

So, if your program's namespace is MyProgram, you should be able to show
the settings via MyProgram.Properties.Settings.Default.xxxx (where xxxx
is whatever setting you're looking for, of course).

Pete

I wander if I screwed things up here. I have several classes that
serve a similar purpose. All of them are in the name space,
"MyProgram". Then later, just to fool around with the IDE, I decided
to create a folder, "Items", in the Solution Explorer, and move all
the classes to that folder, since they do similar work. If I create a
new class within the folder, the namespace comes up as
"MyProgram.Items". The other classes, of course, do not have this NS.

Is that a bad policy?

Dom
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Dom said:
I wander if I screwed things up here. I have several classes that
serve a similar purpose. All of them are in the name space,
"MyProgram". Then later, just to fool around with the IDE, I decided
to create a folder, "Items", in the Solution Explorer, and move all
the classes to that folder, since they do similar work. If I create a
new class within the folder, the namespace comes up as
"MyProgram.Items". The other classes, of course, do not have this NS.

Is that a bad policy?

Moving classes to folders?
Of course no.
The IDE by default create a new sub namespace per each folder that you add,
sometimes you want it, sometimes you don't. You can simply edit the source
code and remove the sub namespace. I do not recall if this is a config
option in the IDE though.
 
Ad

Advertisements

P

Peter Duniho

rhaazy said:
I think your question would be better suited to a different group,
try: [snip]

In what way is that non-Microsoft-supported, non-Usenet, web-only forum
better than this newsgroup?

And if it is, shouldn't you just post a similar reply to every single
post in this newsgroup?
 
Ad

Advertisements

P

Peter Duniho

Dom said:
That did it. Thanks. Any idea why the immediate window is using the
wrong ns?

Nope. Sorry. I will agree with Ignacio that I doubt this is a
consequence of your moving things into a separate folder, though I can't
rule it out. Doing that does, as you noticed, change the default
namespace for new things, but I don't see why it'd affect how the
immediate window chooses namespaces.

I have precious little experience using the immediate window though, so
I don't have anything useful to offer with respect to why it does what
it does. Sorry.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top