locked
debug assertion failed afxcoll.inl RRS feed

  • Question

  • I`m making a dll and we use Cstringarray type,  this type use afxcoll library.

    When compile and link all go ok, at the end run regsvr32 and appear the following error:

    "Debug Assertion Failed!

    Program Windows : C:\Windows\SysWOW64\regsvr32.exe 

    File f:\dd\tools\vc7libs\ship\atlmfc\include\afxcoll.inl  Line: 305

    For information on how your programcan cause an assertion failure, see Visual C++ documentation on asserts."

    What kind of fault is? I need to add this reference in another project but if is not registered I can not add this dll.

    How I have to do to find what problem is it?

    I´ll appreciatte any help from you. 

    Regards,

    • Moved by Jesse Jiang Wednesday, December 19, 2012 9:07 AM forum close (From:Visual C++ MFC and ATL)
    Monday, December 10, 2012 9:54 PM

Answers

  • Hard to guess without your code, but you are probably doing too much in InitInstance, which is called by DllMain.


    Visual C++ MVP

    • Marked as answer by Elegentin Xie Tuesday, December 25, 2012 5:35 AM
    Monday, December 10, 2012 10:07 PM
  • Sheng Jiang : 

    You are right, the trouble was in InitInstance. I was making an initialization in there, I change my function out there and the dll was registered ok.

    Thank you to your answer, Scott and Renjitt, too.

    Regards,

    • Proposed as answer by Elegentin Xie Friday, December 14, 2012 9:21 AM
    • Marked as answer by Elegentin Xie Tuesday, December 25, 2012 5:35 AM
    Wednesday, December 12, 2012 11:32 AM

All replies

  • Hard to guess without your code, but you are probably doing too much in InitInstance, which is called by DllMain.


    Visual C++ MVP

    • Marked as answer by Elegentin Xie Tuesday, December 25, 2012 5:35 AM
    Monday, December 10, 2012 10:07 PM
  • You can investigate the problem by running the debug build of your DLL in the debugger.

    Change the project properties debugging settings command line to something like

    regsvr32 your.dll

    The debugger will start regsvr32, which will load and call your DLL. When the assertion error occurs the debugger will halt the program. Examine afxcoll.inl line 305 and examine the debugger stack window to see how you got to there from your code.

     

     

    Monday, December 10, 2012 10:32 PM
  • Try  attaching regsvr32 with VS and click on Retry button in abort and Press break. Then check call stack by which you will get the actual location of code 

    Thanks, Renjith V R

    Tuesday, December 11, 2012 2:42 PM
  • Thanks for your quiclly answer.

    I tried to run regsvr32 my.dll, without visual studio enviroment, but appear the same message.

    I saw the line 305 in afxcoll.inl  and this is: 

    304 _AFXCOLL_INLINE CString& CStringArray::ElementAt(INT_PTR nIndex)
    305 { ASSERT(nIndex >= 0 && nIndex < m_nSize);
    306 if( nIndex < 0 || nIndex >= m_nSize )
    307 AfxThrowInvalidArgException();
    308 return m_pData[nIndex]; }

    Another way, the error messages talk about no exist path in my computer : 

    f:\dd\tools\vc7libs\ship\atlmfc\include\afxcoll.inl 

     f disk don`t exist, rest of path until atlmfc neither,  and the afxcoll.inl file exist in folowing path:

    C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include

    I don`t understand the bad path, and I don`t understand the error messages, I only like to use CstringArray in my code for this reason appear all relation with afxcoll.h header. 

    I`ll check init instance like Sheng Jiang say,  and I`ll check stack like Scott say. 

    Any other help will be appreciatte.

    Tuesday, December 11, 2012 2:45 PM
  • >> I don`t understand the bad path, and I don`t understand the error messages

    The path is not important: It is the path that Microsoft used when compiling the library. The ASSERT check has detected that you are accessing the array with an invalid index.

    Tuesday, December 11, 2012 3:17 PM
  • Sheng Jiang : 

    You are right, the trouble was in InitInstance. I was making an initialization in there, I change my function out there and the dll was registered ok.

    Thank you to your answer, Scott and Renjitt, too.

    Regards,

    • Proposed as answer by Elegentin Xie Friday, December 14, 2012 9:21 AM
    • Marked as answer by Elegentin Xie Tuesday, December 25, 2012 5:35 AM
    Wednesday, December 12, 2012 11:32 AM
  • Hi,

    I have marked these replies as answers.
    If you disagree, please unmark them, and post your doubt.

    Regards,


    Elegentin Xie
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 25, 2012 5:35 AM