I'm trying to link the C++ defined libraries , so that they be used in C#. I have an CString PastUsed that holds a variable in C++, which I'm trying to access in C#.
In C++, I stored the value of the variable PastUsed in the '.odl' file as BSTR PastUsed. I'm using DISP_PROPERTY_EX as a dispatch map.
DISP_PROPERTY_EX(Cpctr, "PastUsed", GetPastUsed, SetPastUsed, VT_BSTR). I return the value of the String variable from GetPastUsed. But, I donot think this value is being saved in PastUsed (as defined in .odl). This I'm assuming is happening because when I try to access this variable (PastUsed from .odl) in C#, I get a com exception.
The code I have in c# to retrieve the C++ defined variable is:
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; } The PastUsed (here above one in c#) is the same string which is supposed to be containing the variable held in Pastused of c++ (as described in my first post). As soon as it hits the breakpoint of String str in c#, I get the exception:
Print.PastUsed = 'Print.PastUsed' threw an exception of type 'System.Runtime.InteropServices.COMException'