Linking c++ and c#
<p>I'm trying to link the C++ defined libraries , so that they be used in C#.
I have an <code>CString PastUsed</code> that holds a variable in C++, which I'm trying to
access in C#.</p>

<p>In C++, I stored the value of the variable <code>PastUsed</code> in the '.odl' file as
<code>BSTR PastUsed</code>.  I'm using <code>DISP_PROPERTY_EX</code> as a dispatch map.</p>

<pre><code>DISP_PROPERTY_EX(Cpctr, "PastUsed", GetPastUsed, SetPastUsed, VT_BSTR).
</code></pre>

<p>I return the value of the String variable  from <code>GetPastUsed</code>.
But, I donot think this value is being saved in <code>PastUsed</code> (as defined in
.odl). This I'm assuming is happening because when I try to access this
variable (<code>PastUsed</code> from .odl) in C#, I get a com exception.</p>

<p>The code I have in c#  to retrieve the C++ defined variable is:</p>

<pre><code>private void GetPastUsedDes_Click(Object eventSender, EventArgs eventArgs) 
{
    if (CheckInvalidButtonClick())
    { 
        return;
    } 
    PrintLine("Dumping past Used"); 
    AxPBSPRINTLib.AxPBSprint sPrint = mPBSPrintCtrl; 
    String str = mPBSPrintCtrl.PastUsed;
    String str = Print.PastUsed;
}
</code></pre>

<p>The <code>PastUsed</code> (here above one in c#) is the same string which is supposed to
be containing the variable held in <code>Pastused</code> of c++ (as described in my first
post). As soon as it hits the breakpoint of String str in c#, I get the
exception:</p>

<pre><code>Print.PastUsed = 'Print.PastUsed' threw an exception of type 'System.Runtime.InteropServices.COMException'
</code></pre>
