calling a Lotus Notes c++ API LNSmartPtr base class

mossse

New member
Joined
Sep 4, 2014
Messages
1
Programming Experience
5-10
Hi I am having an access violation calling one of the functions =>LNDatabase
Below is my code:
LNDatabase LND = new LNDatabase();
public IntPtr m_pNativeObject;  // Variable to hold the C++ class's this pointer                
public LNDatabase()
{
            LNSmartPtr LNS = new LNSmartPtr(); //Call 1st the base class
            // We have to Create an instance of this class through an exported function
            //this.m_pNativeObject = nnotesDLL.LNDatabase(m_pNativeSmartLNSmartPtrObject);
            this.m_pNativeObject = IntPtr.Zero;
}
// ....
public class LNSmartPtr
    {
        public IntPtr m_pNativeObject;  // Variable to hold the C++ class's this pointer
        public LNSmartPtr()
        {   
            // We have to Create an instance of this class through an exported function
            this.m_pNativeObject = nnotesDLL.LNSmartPtr();
        }
    }

==================================================================
[DllImport("lcppn803.DLL", EntryPoint = "??_7LNSmartPtr@@6B@", CallingConvention = CallingConvention.StdCall)]
public unsafe static extern IntPtr LNSmartPtr();
==================================================================

==== DumpBin Yields the following different functions - LNCPP80.DLL
??0LNSmartPtr@@QAE@ABV0@@Z
??0LNSmartPtr@@QAE@PAVLNBody@@@Z
??0LNSmartPtr@@QAE@XZ
??1LNSmartPtr@@QAE@XZ
??4LNSmartPtr@@QAEAAV0@ABV0@@Z
??4LNSmartPtr@@QAEAAV0@PAVLNBody@@@Z
??_7LNSmartPtr@@6B@ ===> This is the correct one to call

================================ Lotus Notes C++ API ToolKit has the following for LNDatabase ==>lndb.hpp
C#:
//  Class definition for LNDatabase.
//
class LNIMPEXPCL LNDatabase : public LNSmartPtr
{
friend class LNCalendar;
friend class LNCalendarEntryArray;
friend class LNNote;
friend class LNNoteArray;
friend class LNNotesSession;
public:
  LNDatabase() : LNSmartPtr() {}
  LNDatabase( const LNDatabase &other ) : LNSmartPtr(other) {}
  ~LNDatabase() {}
  
  LNDatabase & operator=( const LNDatabase &other );
================================ Lotus Notes C++ API ToolKit has the following for LNSmartPtr ==>lndb.hpp
C#:
/  Description:
//
//  LNSmartPtr is the base class for all smart pointer classes. Note that the
//  copy constructor and assignment operator in each derived class must invoke
//  the base class versions. Note also that LNSmartPtr does not inherit from
//  LNNotesClass, to keep it as small as possible.
//---------------------------------------------------------------------------
class LNIMPEXPCL LNSmartPtr
{
public:
  LNSmartPtr() { Body = 0; }
  LNSmartPtr( LNBody *body );
  LNSmartPtr( const LNSmartPtr &ptr );
  ~LNSmartPtr() { DeleteBody(); }
  LNSmartPtr & operator=( const LNSmartPtr &ptr );
  LNSmartPtr & operator=( LNBody *body );
  virtual LNBOOL DeleteBody();
  virtual LNCLASSID GetClassID() const = 0;
  virtual const char * GetClassName() const
#ifdef EBCDIC_TRANSLATION_REQUIRED
    { return LNGetClassName(GetClassID(), TRUE); }
#else
    { return LNGetClassName(GetClassID(), FALSE); }
#endif
  virtual LNNotesSession * GetSession() const
  {
    if (Body)
      return ((LNNotesClass *) Body)->GetSession();
    return 0;
  }
  //  { return (Body ? ((LNNotesClass *) Body)->GetSession() : 0); }
  virtual LNBOOL IsNull() const { return Body == 0; }
protected:
  LNBody *Body;
};
 
Last edited by a moderator:
Back
Top Bottom