Unhandled exception while using safearrays


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Unhandled exception while using safearrays

  1. #1
    Geetha Guest

    Unhandled exception while using safearrays




    One of my methods in the component is returning an array(SAFEARRAY) of UDT.
    While accessing the return value of this method which is a SAFEAARAY , it
    throws an error - Unhandled exception..... :Access violation

    Function declaration is as follows
    Method1(SAFEARRAY **);

    SAFEARRAY *psa;
    myobj.List(&psa);
    UDTx *m_udt =NULL;

    hr = SafeArrayAccessData(psa, reinterpret_cast<PVOID*>(&m_udt));
    where m_udt is of type UDTx.

    SafeArrayUnaccessData(psa);

    while accesssing SafeArrayAccessData it throws up an error Unhandled exception.....
    :Access violation



  2. #2
    James Barbetti Guest

    Re: Unhandled exception while using safearrays


    Hi Geetha.

    >One of my methods in the component is returning an array(SAFEARRAY)
    >of UDT.
    >While accessing the return value of this method which is a SAFEAARAY , it
    >throws an error - Unhandled exception..... :Access violation
    >
    >Function declaration is as follows
    >Method1(SAFEARRAY **);
    >
    >SAFEARRAY *psa;
    >myobj.List(&psa);
    >UDTx *m_udt =NULL;
    >
    >hr = SafeArrayAccessData(psa, reinterpret_cast<PVOID*>(&m_udt));
    >where m_udt is of type UDTx.
    >
    >SafeArrayUnaccessData(psa);
    >
    >while accesssing SafeArrayAccessData it throws up an error Unhandled exception.....
    >:Access violation


    Can only help you if it's a null dereference. You should be checking that
    that ...

    1) psa!=NULL
    2) psa->pvData!=NULL

    it's quite possible that one of the two is NULL, if you haven't taken care
    to initialize the SAFEARRAY structure properly in ...

    myobj.List(&psa);

    I hope for your sake it's one of those two problems. If it's *bad* rather
    than NULL addresses you're in trouble.
    Seeya,
    James


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center