Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ Virtual Table Error?
    primarykey
    data
    text
    <p>I have the following structure:</p> <pre><code>//Unmanaged(.h) class myInterface { public: virtual bool Send(char* myChar); } //Managed (.h) class myClass; public ref class Parser { bool Transmit(String^ mString); } class myClass : public myInterface { public: virtual bool Send(char* myChar); private: gcroot&lt;Parser^&gt; pParser; } </code></pre> <p>My problem is that somewhere in my unmanaged code, i must call the Send function. It calls the function from the Managed code Send, but, the Send function calls the Transmit Method from the Parser class. The problem is that when I Debug, the pParser instance is empty (even if i already had instantiated it before in the Constructor).</p> <p>Is this a Garbage Collector Issue or a Virtual Table mislead ? How can i Fix it ? Thanks !</p> <p><strong>UPDATE:</strong> After some further Debugging, i've realized that if i included other instances of gcroot for example: </p> <p><code>gcroot&lt;AppDomaion^&gt; pDomain;</code> </p> <p>and then, in the code, tried to run: </p> <p><code>pDomain = AppDomain::CurrentDomain;</code></p> <p>The Debugger would show the same empty value as for the pParser. Is there something wrong with what i'm doing ? should I instantiate the class in a different way ?</p> <p><strong>UPDATE2:</strong></p> <p>The Managed/Unmanaged goes something like this:</p> <p>Wrapper:(wrapper.h)</p> <pre><code>public ref class Wrapper { public: Send(String^ mSendMessage); Parse(String^ mMessageString); ... private: ComLayer* mComm; CInferface mInterface; }; private class CInterface : public IIterface { public: virtual bool Deliver(CMessage mMessage); ... private: gcroot&lt;Wrapper^&gt; mParent; }; </code></pre> <p>Wrapper(wrapper.cpp)</p> <pre><code>Wrapper::Send(String^ mSendMessage) { ... mComm-&gt;Send(mMessage); } Wrapper::Parse(String^ mMessageString) { ... } CInterface::Deliver(CMessage* mMessage) { ... //Here, mParent value is empty under Labview, not while Debug/VS/WindowsForm mParent-&gt;Parse(mMessageString) } </code></pre> <p>Unmanaged:(commLayer.h)</p> <pre><code>class CommLayer { public: //Send: bool Send(CMessage* mMessage); ... private: //instead of CInterface, IInterface. IInterface mInterface; }; </code></pre> <p>Unmanaged:(IInterface.h)</p> <pre><code>class IInterface { public: //Response: virtual bool Deliver(CMessage mMessage); }; </code></pre> <p>The problem is that when the unmanaged code calls the mInferface->Deliver(mMessage) ; There is no instance for mParent. Then, in the Wrapper, mParent is empty (value = null); Is like it would only access the methods from the Unmanaged IInterface and not the Wrapper^ from the wrapper CInterface.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload