importing function from c++ that returns structure
<p>I have this structure in my c++ application:</p>

<pre><code>struct Animation
{
    UINT To;
    UINT From;
    USHORT AnimationID;
};

struct Entity
{
    USHORT X, Y;
    UINT SERIAL;
    USHORT SpriteID;
    BYTE DIRECTION;
    USHORT TYPE;
    BOOL Cursed;
    BOOL Fased;
    BOOL IsPet;

    void AddAnimation(Animation &amp;const  a)
    {
        Animations.push_back(a);
    }

    void ClearAnimations()
    {
        this-&gt;Animations.clear();
    }

private:
    vector&lt;Animation&gt; Animations;
};
</code></pre>

<p>I have this exported function:</p>

<pre><code>extern "C" __declspec(dllexport) Entity GetNearest(void)
{
    Entity &amp; result = GetNearestEntity();
    return result;
}
</code></pre>

<p>Is it possible to use this and get the Entity values in c#?</p>

<p>I tried to do this:</p>

<pre><code>  [DllImport("FatBoy.dll", SetLastError = true)]
        internal static extern Entity GetNearest();

        public struct Entity
        {
            ushort X, Y;
            uint SERIAL;
            ushort SpriteID;
            byte DIRECTION;
            ushort TYPE;
            bool Cursed;
            bool Fased;
            bool IsPet;
        }
</code></pre>

<p>When I call it I get the error: </p>

<pre><code>Method's type signature is not PInvoke compatible.
</code></pre>
