A namespace cannot directly contain members... + Type or namespace definition, or end-of-file expected errors
c#, windows-phone
Solution
You get this error because you have neither SERVER nor CLIENT conditional symbol defined. After preprocessing phase eliminates text in #if...#endif directives, compiler sees only this code:
{
/// <summary>
/// Represents the base interface that all offline cacheable object should derive from.
/// </summary>
public interface IOfflineEntity
{
/// <summary>
/// Represents the sync and OData metadata used for the entity
/// </summary>
OfflineEntityMetadata ServiceMetadata { get; set; }
}
}
which is not valid C# code (because "namespace xyz" is missing before opening curly brace).
In Visual Studio go to project properties and on page Build set Conditional compilation symbols to SERVER or CLIENT (names are case sensitive).
Problem
I'm trying to compile the sample code for Sync Framework 4.0 for Windows Phone, however I've encountered an error in few files. One of those files is: ``` #if SERVER namespace Microsoft.Synchronization.Services #elif CLIENT namespace Microsoft.Synchronization.ClientServices #endif { /// <summary> /// Represents the base interface that all offline cacheable object should derive from. /// </summary> public interface IOfflineEntity { /// <summary> /// Represents the sync and OData metadata used for the entity /// </summary> OfflineEntityMetadata ServiceMetadata { get; set; } } } ``` There are two errors: - A namespace cannot directly contain members such as fields or methods -- for the first parenthesis - Type or namespace definition, or end-of-file expected -- for the last parenthesis I've searched through the google for both of those errors and I've found lots of answers for such errors - however none of those can be applied to my case (afaik there are no missing parentheses).