Accessing Properties?

  • Thread starter Thread starter Shak
  • Start date Start date
S

Shak

Hi

My code looks like the follwing:

namespace A.B.C
{
....
private void foo()
{
A.B.C.Properties.Settings.Default.Save();
Properties.Settings.Default.Save() //error
}
}

The error I'm getting is "Cannot access internal property "Properties"
here". Why not though? I thought I was in the correct namespace?

Shak
 
Shak said:
My code looks like the follwing:

namespace A.B.C
{
...
private void foo()
{
A.B.C.Properties.Settings.Default.Save();
Properties.Settings.Default.Save() //error
}
}

The error I'm getting is "Cannot access internal property "Properties"
here". Why not though? I thought I was in the correct namespace?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Jon Skeet said:
Could you post a short but complete program which demonstrates the
problem?

Jon,

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace proptest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
proptest.Properties.Settings.Default.Save();
Properties.Settings.Default.Save(); //red wavy line
}
}
}

This is a windows project that has been created from scratch from VS2005,
with a single setting added to the Settings.settings file, and the above
added to the formload event.

However, it now seems that this is only an "Intellisense" error, and the
file compiles fine and functions normally. It's still annoying though, so if
anyone knows why this is happening I'd appreciate it...

Shak
 
Shak said:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace proptest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
proptest.Properties.Settings.Default.Save();
Properties.Settings.Default.Save(); //red wavy line
}
}
}

That's not a complete program - you haven't shown the other part of the
partial class, or what the Properties class is.
 
Jon Skeet said:
That's not a complete program - you haven't shown the other part of the
partial class, or what the Properties class is.

Apologies, I presumed you didn't want the autogenerated stuff. But it's ok,
I'll live with the fussy intellisense for now. Thanks for the help anyway.

Shak

Shak
 
Back
Top