A namespace cannot directly contain elements ... + Definition of type or namespace or expected errors at the end of a file

I am trying to compile sample code for Sync Framework 4.0 for Windows Phone, however I found an error in several files. One of these files:

#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 elements such as fields or methods - for the first bracket
  • Determining the type or namespace or expected end of file - for the last parenthesis

I searched through google for both of these errors, and I found many answers for such errors - however, none of them can be applied to my case (afaik there are no missing brackets).

+3
source share
2 answers

, SERVER, CLIENT . # if... # 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; }
    }
}

# ( " xyz" , ).

Visual Studio . . SERVER CLIENT ( ).

+4

, .TT UNIX, -, , git. .tt , , Visual Studio .

0

All Articles