locked
error when hosting WPF control inside of a Winform Application RRS feed

  • Question

  • Hello All,

    I am trying to follow the example for hosting a WPF Control inside of a Windows Forms. While I am doing that it compiles successfully, but I get the error that:

    "NET20andXAML.vshost.exe has encountered a problem and needs to close. We are sorry for the inconvenience."

    Any help on this?

     

    I am using the WindowsFormIntegration Examples using the

    private void Form1_Load(object sender, EventArgs e)

    {

    // Create the ElementHost control for hosting the

    // WPF UserControl.

    ElementHost host = new ElementHost();

    host.Dock = DockStyle.Fill;

    // Create the WPF UserControl.

    XAML.UserControl1 uc =

    new XAML.UserControl1();

    // Assign the WPF UserControl to the ElementHost control's

    // Child property.

    host.Child = uc;

    // Add the ElementHost control to the form's

    // collection of child controls.

    this.Controls.Add(host);

    }

    .

    Monday, October 9, 2006 10:51 PM

All replies

  • Hi Laadlaa,

    I haven't been able to reproduce your issue. Can you supply your machine configuration and the version of the WinSDK you're using?

    Jim Galasyn

    .NET Client User Education

     

    Tuesday, October 10, 2006 6:13 PM
  • OS Name    Microsoft Windows XP Professional
    Version    5.1.2600 Service Pack 2 Build 2600
    OS Manufacturer    Microsoft Corporation
    System Name    ###########
    System Manufacturer    Dell Inc.
    System Model    Latitude D810
    System Type    X86-based PC
    Processor    x86 Family 6 Model 13 Stepping 8 GenuineIntel ~2128 Mhz
    BIOS Version/Date    Dell Inc. A03, 07/04/2005
    SMBIOS Version    2.3
    Windows Directory    C:\WINDOWS
    System Directory    C:\WINDOWS\system32
    Boot Device    \Device\HarddiskVolume1
    Locale    United States
    Hardware Abstraction Layer    Version = "5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)"
    User Name    ###########
    Time Zone    Mountain Daylight Time
    Total Physical Memory    2,048.00 MB
    Available Physical Memory    1,012.66 MB
    Total Virtual Memory    2.00 GB
    Available Virtual Memory    1.96 GB
    Page File Space    5.35 GB
    Page File    C:\pagefile.sys


    Microsoft Visual Studio 2005
    Version 8.0.50727.42  (RTM.050727-4200)
    Microsoft .NET Framework
    Version 2.0.50727

    Installed Edition: Professional

    Microsoft Visual Basic 2005  
    Microsoft Visual Basic 2005

    Microsoft Visual C# 2005  
    Microsoft Visual C# 2005

    Microsoft Visual C++ 2005  
    Microsoft Visual C++ 2005

    Microsoft Visual J# 2005  
    Microsoft Visual J# 2005

    Microsoft Visual Studio 2005 Tools for Applications  
    Microsoft Visual Studio 2005 Tools for Applications

    Microsoft Visual Web Developer 2005  
    Microsoft Visual Web Developer 2005

    Crystal Reports   
    Crystal Reports for Visual Studio 2005


    IndexedFind   1.0
    Finds strings in files using Microsoft Indexing Service.

    Orcas Technology Preview - .NET Framework 3.0 Development Tools   1.0
    Microsoft Visual Studio Code Name Orcas Community Technology Preview - Development Tools for WinFX

    PowerToysMaster   1.0
    Provides the Power Toys submenu.

    Quality Center Package   QC Package Prooduct ID
    Quality Center Visual Studio integration package


    I have the following version of SDK:


    Microsoft ® Windows ® SDK Release Notes for September Customer Technology Preview

    Version Sept CTP 1.0.0.0

    And it does say that it supports

    Important This version of the Windows SDK targets specific versions of Windows and has other restrictions. This version:

    • Is supported on Windows Vista September CTP, which is available from the MSDN Universal Subscribers site on MSDN and from the Beta customer locations.
    • Supports .NET Framework 3.0 September CTP for Windows XP SP2 and Windows Server 2003 SP1, which is available publicly from the Download Center.
    Tuesday, October 10, 2006 7:35 PM
  • After glancing it over, your configuration looks reasonable. Did you have earlier verions of the SDK installed before you installed Sept. CTP?

    Also, can you try going the other direction, hosting a WinForms control in WPF? You can use this sample:

    Hosting a Windows Forms Control in Windows Presentation Foundation Sample 

    I'm just wondering if interop is broken in both directions.

    Jim

     

    Tuesday, October 10, 2006 8:01 PM
  • I think its a problem with the installation, since I had the earlier versions of the SDK and now that I uninstalled it seems there are still some left overs somewhere giving the problem, on the machine with a clean image and new install it works just fine.

    Dont know why though, I am going to see if there is any setting in the registry, if you have any other clue please let me know. I am not sure where are Microsoft people if they are reading this, how come there is no reply.

     

    Laadlaa

     

    Wednesday, October 11, 2006 8:17 PM
  • I've had similar problems in the past with old installations. You might want to try this tool:

    Pre-released Microsoft .NET Framework 3.0 Uninstall Tool

    I've had some success with this in the past. Fwiw, I had an issue with the RC1 bits, but when I uninstalled and installed the RTM bits, it went away. Unfortunately, RTM bits aren't publicly available yet, so I hope you have some luck with the uninstall tool.

    Jim

    Wednesday, October 11, 2006 8:27 PM