LNK2022: metadata operation failed: inconsistent field declarations in duplicate types

I have a problem compiling my .NET.NET project.

I read “LNK2022: metadata operation failed” making me crazy - and this is not my business because in my case I cannot compile one project - it does not work during communication. I tried all (two) solutions to this topic, and it did not help me.

These errors started to grow only when I changed the class to the template class. I have a Vector2Di class (for an int type), and now you need exactly the same thing for a float type, so I renamed it to Vector2D and changed it to use a template, now I have:

template <class T>
public ref class Vector2D : NativeValue<irr::core::vector2d<T>>
{
...
}

typedef Vector2D<int> Vector2Di;
typedef Vector2D<float> Vector2Df;

And he began to detect linker errors:

LNK2022: (80131188): (: NativeValue > ; fields: m_NativeValue): (0x04000058).

LNK2022: (8013118B): (: NativeValue > ; : System.IDisposable): (0x09000005).

.

: Vector2D .NET ++ valuetype class vector2d ( ). , , , valuetype ref ( apears), valuetype, -, ref class NativeValue - , - .

:

    template <class T>
    ref class NativeValue
    {
    public:

        ~NativeValue()
        {
            this->!NativeValue();
        }

        !NativeValue()
        {
            if (m_NativeValue != nullptr)
            {
                delete m_NativeValue;
                m_NativeValue = nullptr;
            }
        }

    internal:

        T* m_NativeValue;

    protected:

        NativeValue() {}
    };

, . , cpp - .

stdafx.cpp, (, Vector2D) stdafx.h; stdafx.h .

, -, , . .

+5
1

. , this, , .

0

All Articles