且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

命名空间不能直接包含成员.+类型或命名空间定义,或文件结尾预期错误

更新时间:2021-11-30 17:39:26

您会收到此错误,因为您既没有定义服务器,也没有定义客户端conditional symbol。预处理阶段消除#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; }
    }
}

这不是有效的C#代码(因为在打开大括号之前缺少"命名空间xyz")。

在Visual Studio中,转到"项目属性",并在"生成"页上将条件编译符号设置为服务器或客户端(名称区分大小写)。