我有一个标题看起来像这样:

    namespace Dummy
    {
        ref class ISYSession {};

        namespace Afw
        {
            /// <summary>Sammlung von AFW-Utility-Methoden</summary>
            public ref class AfwUtility
            {
            public:
                static void CopyAFWParamsToIDictionary(AFWParams &parameterIn, System::Collections::IDictionary^ parameterOut);
                static AFWParams* CopyIDictionaryToAFWParams(System::Collections::IDictionary^ dictionary);
                static void ShowExceptionLog(System::String^ sessionId);
                static void ShowStatementLog(System::String^ sessionId);
                static Dummy::ISYSession^ GetSession(AFWAppClass *acl);
            };
        }
    }

如果我没有为我的ref类使用 header ,则无法在同一程序集中使用它。但是有了这个头文件,我的代码就不再编译了。

这些是前两个错误:

c:\ develop ... \ xy.dll:警告C4944:'ISYSession':Das Symbol kann nicht aus'c:\ develop ... \ xy.dll'importiert werden:'Dummy::ISYSession'ist beitits im aktuellen贝里希·沃汉登(Bereich vorhanden)。

(英语:“'Dummy::ISYSession':无法从xy.dll导入符号:Dummy::ISYSession已存在于当前范围中。”)

错误C3699:“^”:正常工作“Schleupen::CS::SY::ISYSession”正常工作。

(英语:“此引用不能用于'Dummy::ISYSession'类型。”)

这应该如何工作?对我来说,似乎编译器认为ISYSession ref类是在同一程序集中定义的(不是,而是在不同的.NET DLL中定义的)。

最佳答案

    ref class ISYSession {};

那不是前向声明,而是没有成员的类的实际类定义。固定:
    ref class ISYSession;

10-08 07:36