Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF throwing an exception parsing XAML that includes a Winforms User Control
    text
    copied!<p>I have a WPF app that makes use of a Winforms User Control that I have created using C++/CLI. When my app goes to parse the XAML for my main window, it throws an exception. The information appears to be somewhat abbreviated, but it says:</p> <pre><code>A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll Additional information: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1) Error in markup file 'OsgViewer;component/osgviewerwin.xaml' Line 1 Position 9. </code></pre> <p>I commented out my Winforms control in the XAML and everything loads fine. I figured maybe the constructor for my control is doing something bad, so I put a breakpoint in it, but the breakpoint does not appear to be enabled when I start to run the app, and is never hit, which I understand to mean the DLL containing that line is not loaded. Which would most likely cause an exception to be thrown when an object of a type in the DLL is instantiated - the body of the object's constructor couldn't be found.</p> <p>I have done this successfully on a different project in the past, so I pulled in a different WinForms User Control from that app, and instantiated it in the XAML, and that all works fine.</p> <p>So it's something in this DLL. I have a reference to the DLL in my WPF C# app, and when I load the DLL in Object Browser all the required classes and namespaces show up fine. The app compiles fine, the problem just shows up when parsing the XAML. Anybody seen something like this? Any ideas as to what could be causing this? Ideas for debugging it? Thanks!</p> <pre><code>&lt;Window x:Class="OsgViewer.OsgViewerWin" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:int="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" xmlns:myns="clr-namespace:MyGlobalNS.MyNS;assembly=MyAssembly" ... &lt;int:WindowsFormsHost x:Name="m_Host"&gt; &lt;myns:CMyClass x:Name="m_MyClass" /&gt; &lt;/int:WindowsFormsHost&gt; ... &lt;/window&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload