.NET Framework Developer Center > .NET Development Forums > Common Language Runtime > Unable to get the window handle for the 'AxNLevel2' control. Windowless ActiveX controls are not supported.
Ask a questionAsk a question
 

AnswerUnable to get the window handle for the 'AxNLevel2' control. Windowless ActiveX controls are not supported.

  • Thursday, January 17, 2008 8:59 PMTom Frey Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

     

    I'm having an issue with an ActiveX control that is just driving me nuts right now. The weird part is this always worked just fine and now it suddenly doesn't anymore and I have no idea why.

    I have an ActiveX control on a form (it's NOT a windowless ActiveX control!) and when I launch the app in the VS debugger everything works just fine. However, when I launch the app standalone without debugger attached it throws an Exception here:

     

    InitializeComponent()

    {

    ....

    ((System.ComponentModel.ISupportInitialize)(this.Level2)).EndInit();

    }

     

    --> Unable to get the window handle for the 'AxNLevel2' control. Windowless ActiveX controls are not supported.

     

    What's even weirder: I tried the compiled app on several machines, on most it throws this exception. On my primary dev machine it NEVER throws the exception, no matter if I run it standalone or in the debugger. On another dev machine it throws the exception when run standalone but not when the debugger is attached.

     

    I'm really out of ideas here... if anyone has any idea please let me know.

     

    Thanks,

     

    Tom

Answers

  • Thursday, January 17, 2008 9:37 PMTom Frey Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    oh whow, I just figured out what the issue is and why it "suddenly" stopped working without any code changes:

     

    Starting with Framework 2.0 SP1 every compiled image contains the IMAGE_DLLCHARACTERISTICS_NX_COMPAT Flag in the PE Header. (See: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2570434&SiteID=1)

    This means that an application that is compiled with VS2005 or VS2008, with .NET 2.0 SP1 installed, can not use older ActiveX-Controls (e.g. from third parties) which are using ATL 7.1 or earlier. DEP (active in Vista by default, inactive in XP by default) detects an access violation when the constructor of the ActiveX-Control is called.

     

    Thankfully I found a workaround:

     

    http://blogs.msdn.com/ed_maurer/archive/2007/12/14/nxcompat-and-the-c-compiler.aspx

     

All Replies

  • Thursday, January 17, 2008 9:37 PMTom Frey Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    oh whow, I just figured out what the issue is and why it "suddenly" stopped working without any code changes:

     

    Starting with Framework 2.0 SP1 every compiled image contains the IMAGE_DLLCHARACTERISTICS_NX_COMPAT Flag in the PE Header. (See: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2570434&SiteID=1)

    This means that an application that is compiled with VS2005 or VS2008, with .NET 2.0 SP1 installed, can not use older ActiveX-Controls (e.g. from third parties) which are using ATL 7.1 or earlier. DEP (active in Vista by default, inactive in XP by default) detects an access violation when the constructor of the ActiveX-Control is called.

     

    Thankfully I found a workaround:

     

    http://blogs.msdn.com/ed_maurer/archive/2007/12/14/nxcompat-and-the-c-compiler.aspx

     

  • Friday, October 03, 2008 4:49 PMMartin0 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
     Thanks for info

    I just delete all components of thirty party user control in dispose(), then it works.
    Martin