From: Andrew Falanga on
Hi,

The code in which this is happening is too large to post here, not to
mention, I can't post snippets from this code here. So, right up
front, I know that the problem may be masked in whatever "skeleton"
code I write below. Never the less, it's all I've got to work with at
this point.

So, the question is simply, why would a public class not be "visible"
to other classes and methods within the same namespace? In fact,
using .NET reflector, I don't see this class either. So, here's what
I have, roughly:

In file1:

namespace some.name.space {
public class SingletonClass {
private SingletonClass instance = null;

public static SingletonClass Instance() {
if(instance == null)
instance = new SingletonClass();
return instance;
}

// private ctor and other stuff
}
}

Then, in file2:

namespace some.name.space {
public ClassInFile2 {
ClassInFile2() {
SingletonClass.Instance().<call_some_method>;
}
}
}

I don't understand why, but I cannot see SingletonClass in file 2,
even though SingletonClass is typed as public AND they're both in the
same namespace AND part of the same solution. What's further odd, the
SingletonClass doesn't show up in .NET reflector. What gives? What
subtle aspect of access modifiers am I missing?

Again, I know that it's much more difficult to help without the code
I'm actually working. Again, I simply can't paste snippets from that
code here.

Thanks,
Andy
From: Harlan Messinger on
Andrew Falanga wrote:
> Hi,
>
> The code in which this is happening is too large to post here, not to
> mention, I can't post snippets from this code here. So, right up
> front, I know that the problem may be masked in whatever "skeleton"
> code I write below. Never the less, it's all I've got to work with at
> this point.
>
> So, the question is simply, why would a public class not be "visible"
> to other classes and methods within the same namespace? In fact,
> using .NET reflector, I don't see this class either. So, here's what
> I have, roughly:
>
> In file1:
>
> namespace some.name.space {
> public class SingletonClass {
> private SingletonClass instance = null;
>
> public static SingletonClass Instance() {
> if(instance == null)
> instance = new SingletonClass();
> return instance;
> }
>
> // private ctor and other stuff
> }
> }

Is the actual class error-free?

> Then, in file2:
>
> namespace some.name.space {
> public ClassInFile2 {

Is the word "class" omitted in the actual code as it is here?

> ClassInFile2() {
> SingletonClass.Instance().<call_some_method>;
> }
> }
> }
>
From: Family Tree Mike on
On 5/6/2010 2:53 PM, Andrew Falanga wrote:
> Hi,
>
> The code in which this is happening is too large to post here, not to
> mention, I can't post snippets from this code here. So, right up
> front, I know that the problem may be masked in whatever "skeleton"
> code I write below. Never the less, it's all I've got to work with at
> this point.
>
> So, the question is simply, why would a public class not be "visible"
> to other classes and methods within the same namespace? In fact,
> using .NET reflector, I don't see this class either. So, here's what
> I have, roughly:
>
> In file1:
>
> namespace some.name.space {
> public class SingletonClass {
> private SingletonClass instance = null;
>
> public static SingletonClass Instance() {
> if(instance == null)
> instance = new SingletonClass();
> return instance;
> }
>
> // private ctor and other stuff
> }
> }
>
> Then, in file2:
>
> namespace some.name.space {
> public ClassInFile2 {
> ClassInFile2() {
> SingletonClass.Instance().<call_some_method>;
> }
> }
> }
>
> I don't understand why, but I cannot see SingletonClass in file 2,
> even though SingletonClass is typed as public AND they're both in the
> same namespace AND part of the same solution. What's further odd, the
> SingletonClass doesn't show up in .NET reflector. What gives? What
> subtle aspect of access modifiers am I missing?
>
> Again, I know that it's much more difficult to help without the code
> I'm actually working. Again, I simply can't paste snippets from that
> code here.
>
> Thanks,
> Andy

Fixing the errors in the code above, as you suspected, does not
illustrate your problem. The errors I see are that you need a static
keyword on the declaration of SingletonClass.instance, and a class
keyword in the class definition for ClassInFile2.

Is by chance ClassInFile2, actually in a separate project?

--
Mike
From: Andrew Falanga on
>
> Is the actual class error-free?
>
> > Then, in file2:
>
> > namespace some.name.space {
> >    public ClassInFile2 {
>
> Is the word "class" omitted in the actual code as it is here?
>
> >       ClassInFile2() {
> >          SingletonClass.Instance().<call_some_method>;
> >       }
> >    }
> > }

The code is error free and compiles. That was a typo on my part.
Can't believe I missed that one.

Andy
From: Jeff Johnson on
"Andrew Falanga" <af300wsm(a)gmail.com> wrote in message
news:27c2f003-e291-45ee-9279-c5a308dd8dbc(a)o11g2000yqj.googlegroups.com...

> I don't understand why, but I cannot see SingletonClass in file 2,
> even though SingletonClass is typed as public AND they're both in the
> same namespace AND part of the same solution. What's further odd, the
> SingletonClass doesn't show up in .NET reflector. What gives? What
> subtle aspect of access modifiers am I missing?

Are they part of the same assembly?