Re: Reg. Access Violation When Accessing STL Object between a DLL and
From: Doug Harrison [MVP] (dsh_at_mvps.org)
Date: 02/28/05
- Next message: Muthu Nivas: "Re: Reg. Access Violation When Accessing STL Object between a DLL"
- Previous message: Muthu Nivas: "Reg. Access Violation When Accessing STL Object between a DLL and"
- In reply to: Muthu Nivas: "Reg. Access Violation When Accessing STL Object between a DLL and"
- Next in thread: Muthu Nivas: "Re: Reg. Access Violation When Accessing STL Object between a DLL"
- Reply: Muthu Nivas: "Re: Reg. Access Violation When Accessing STL Object between a DLL"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 28 Feb 2005 10:19:46 -0600
Muthu Nivas wrote:
>Hi all,
> One of MS KB article explains that there might be access violation when
>we access a STL object created in one DLL or EXE through a pointer or
>reference in a different DLL or EXE (
>http://support.microsoft.com/kb/q172396/ ). To avoid this that article gives
>two resolutions.
>1. If the object is either static, or static data members of a class then we
>need to
> create an accessor method.
>2. If the object is non-static data members of a class that are exported
>from a DLL
> or for automatic data then we have to Export the template class
>instantiation
> from one executable image and import it into the other executable images.
>
> Please refer the above mentioned article for more details.
>
>The same article refers one more article
>http://support.microsoft.com/kb/168958/EN-US/)
>which explains how to export STL Components Inside & Outside of a Class. In
>that it says that map, set, queue, list, deque are all contain nested classes
>and cannot be exported. So does that mean we can NOT have a class in a DLL
>with <map> as a non-static member & use it in the EXE after importing?
>
>Also it says that <basic_string> has been already exported by C Runtime
>DLL(if symbol _DLL is defined), therefore you cannot export them from your
>DLL. If it is already exported then why we need to write accessor methods
>for accessing global string object as mentioned in the sample given in
>article q172396? Also in that sample it does NOT refer a global or static
>but a string object created in heap!!!!
>
>Can anybody clarify this please? Or Please refer some good article or books
>which give more info abt this.
Link all your modules (EXE and DLL) to the same CRT DLLs, and you won't have
to worry about this explicit instantiation and exporting approach. You also
won't have to worry about the modules using different heaps, C-level file
descriptors, errno, etc. However, if you are using VC6, you need to apply
the fixes to <xtree> mentioned here:
http://www.dinkumware.com/vc_fixes.html
-- Doug Harrison Microsoft MVP - Visual C++
- Next message: Muthu Nivas: "Re: Reg. Access Violation When Accessing STL Object between a DLL"
- Previous message: Muthu Nivas: "Reg. Access Violation When Accessing STL Object between a DLL and"
- In reply to: Muthu Nivas: "Reg. Access Violation When Accessing STL Object between a DLL and"
- Next in thread: Muthu Nivas: "Re: Reg. Access Violation When Accessing STL Object between a DLL"
- Reply: Muthu Nivas: "Re: Reg. Access Violation When Accessing STL Object between a DLL"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|