none
exception '0xC0020001: The string binding is invalid.' on application exit

    Question

  • I have a managed app that uses a native library wrapped in a managed wrapper.

    After making adding a wrapped class to the library it started to produce the above exception on exit.

    I couldn't find any help with this specific issue when searching and am posting this in case it helps the next person to have this issue.

    I resolved it by following the the instructions here: http://support.microsoft.com/?id=814472

    The odd thing is that I don't get the linker errors which the article describes.

     

    Tuesday, September 19, 2006 11:49 PM

Answers

  • Hi Glenn,

    I have the very same problem as you. Thanks for letting us know how to resolve this problem.

    However, I am not sure, which resolution in the knowledge base article is the right one for me. Do I have to implement all?

    Maybe you can explain this a bit more? What exactly have you done to get the exception away?

    My application has several mixed-mode DLLs (MFC and managed classes, compiled with /CLR).

    Thanks for your help!

    Jus

     

    Thursday, October 05, 2006 7:18 AM

All replies

  • Hi Glenn,

    I have the very same problem as you. Thanks for letting us know how to resolve this problem.

    However, I am not sure, which resolution in the knowledge base article is the right one for me. Do I have to implement all?

    Maybe you can explain this a bit more? What exactly have you done to get the exception away?

    My application has several mixed-mode DLLs (MFC and managed classes, compiled with /CLR).

    Thanks for your help!

    Jus

     

    Thursday, October 05, 2006 7:18 AM
  • In my case I'm compiling with the /oldclr switch.

    I removed the entry point and added code to call __crt_initialize_dll() and __crt_terminate_dll().

    I thought that they fixed this issue in VC8, so if you are using that and compiling with /clr then it might be a different problem.

     

    Thursday, October 05, 2006 10:03 PM
  • I solved it! The problem was a static CWnd window in one of my classes. After changing the static member to a "normal" member, everything works fine.

    Thanks again for your help.

    Jus

     

    Tuesday, October 10, 2006 9:54 AM
  • Hi,

     

    I am facing same problem  in VS 2005. I have compiled MFC shared DLL Application with /clr option.

    On exiting , my application crashes. On debugging the problem, I found that it throws this exception "0xC0020001: The string binding is invalid" from DllMain routine which has these statements:

     

     

    DllMain ()

    {

    if (dwReason == DLL_PROCESS_DETACH)

    {

    TRACE0("STWprecast.DLL Terminating!\n");

    if (gTheSTWApp != NULL)

    {

    // shut down the sample application

    gTheSTWApp->terminateApplication();

    delete gTheSTWApp; // ---> exception is thrown from this place

    gTheSTWApp = NULL;

    }

     

    }

     

    Note : DllMain function is not Compiled using CLR For reason refer :

    http://technet.microsoft.com/en-us/library/ms235211(VS.80).aspx

     

    Please let me know if you slightest clue about this .

    Thanks

     

    Wednesday, February 27, 2008 7:24 AM
  • Don't call managed code from DLLMain. It's really really bad.

    Monday, January 26, 2009 8:31 PM
  • Chris.P.J said:

    Don't call managed code from DLLMain. It's really really bad.



    The documentation of DllMain is more specific. I am not sure if it is specific about managed code, but it does specify many other things that should not be done in DllMain and managed code is likely to use something that is specifically excluded, such as loading another DLL during a DllMain. I think another is that threads cannot be started during a DllMain. My descriptions are not totally accurate; I assume that everyone that needs to understand will read the documentation themselves.
    Sam Hobbs; see my SimpleSamples.Info
    Thursday, January 29, 2009 5:43 AM
  • I found a different reason for this:

    After I followed the instructions here: http://technet.microsoft.com/en-us/library/ms235211%28v=vs.100%29.aspx

    I got errors that the /clr switch is not set. Finally it was as compiler setting for a single file "dllmain.cpp" which was almost empty, but had set

    Common Language Runtime support to "NO Common Language Runtime Support". Adding the line

    #using <System.Windows.Forms.dll>

    to stdafx.h revealed that.

    Wednesday, February 22, 2012 12:28 PM