Reg. Access Violation When Accessing STL Object between a DLL and

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Muthu Nivas (MuthuNivas_at_discussions.microsoft.com)
Date: 02/28/05


Date: Mon, 28 Feb 2005 00:41:02 -0800

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.

Thanks & Regards,
Muthu Nivas.H



Relevant Pages

  • Re: Editors
    ... some strip them on exe files by default. ... "preferred base address" and, yup, relocations are completely ... DLL files, though, aren't loaded into their own address space but are ... EXE's "entry-point", though, is not "special" in that it's just an ...
    (alt.lang.asm)
  • Re: DLL pass vector by value crash
    ... The prototype for testfunc is a by-value copy, so it has to make a copy of the value. ... Are you using static linking for either the .exe (if so, it probably won't work correctly, ... clearly using the shared CRT DLL for the DLL you are constructing. ... no crash occurs in either config. ...
    (microsoft.public.vc.mfc)
  • Re: DLL pass vector by value crash
    ... stack of the exe and may allocate default member element on the exe heap. ... If this is a dangerous situation, the simple app I set up calling testFunc() ... in a dll did not crash. ... msvcr90.dll!free and access the source code of free.c. ...
    (microsoft.public.vc.mfc)
  • Re: Using same interfaces for in-proc vs. out-proc
    ... for each server) might work better after all. ... TLB,>you reference it in VB and gain access to all ... both EXE and DLL versions must use the same source code; ...
    (microsoft.public.vc.atl)
  • Re: Releasing my VB.NET app over the intranet
    ... of the primary EXE and when compiled I am copying the contents ... the directory and open a browser on the web server and type ... > another dll, we need to put the dll in the same directory, so that the clr ... > The executable will be downloaded to the assembly download cache on the ...
    (microsoft.public.dotnet.framework)