At first, I was unable to reproduce your error.
When these partial classes are defined alone, inside a namespace, the private keyword causes the build to fail with "Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal"...
If I keep them private and nest them within another class, everything works fine.
I can reproduce your error only when, in one file, I have part of the class nested inside another class, and in another file, I do NOT nest the class, and then remove the private keyword... like this:
Class1.cs:
namespace stackoverflow.answers
{
public class Foo
{
private partial class Bar
{
private string SomeProperty { get { return "SomeGeneratedString"; } }
}
}
}
Class2.cs:
namespace stackoverflow.answers
{
partial class Bar
{
void SomeFunction()
{
string bar = this.SomeProperty;
}
}
}
I also get the error you described if the namespaces differ.
Please post the entire code for the solution, because the provided code is invalid C# syntax, and can't be looked into without more context.