WPF Interop w/ Late Binding Optimization


  • Hello all,

    I'm currently drawing WPF content in a Win32 window using latebinding to load the dll at runtime instead of having to reference the project and link to it during compile time.  The problem I'm having is the solution that I'm currently using is very slow (almost 5 seconds just to draw the content to the screen).  I've narrowed it down to essentially one line of code, Activator::CreateInstance (~4s).

    I was hoping someone knew of a way to speed this process up, or have an alternative suggestion to accomplish latebinding to WPF content.  I'll post my code below:

    Assembly^ wpfdll = Assembly::LoadFrom("mydll.dll");

    /* HwndSource stuff */

    Type ^wpfobjtype = wpfdll->GetType("MyWPFType");
    Visual^ v = (Visual^)Activator::CreateInstance(wpfobjtype);    // -- this is the slow line of code

    hwndsource->RootVisual = v;

    Please Help! Smile
    Tuesday, May 20, 2008 7:35 PM