I can not adequately add a link to the WPF user element library created inside the WinForm project; the link is identified with an exclamation mark, without any obvious errors, and the elementHost empty. Ps. Once I added it and worked fine (I made the library myself).

Additionally

The variable 'userControl11' is either not declared or has not been assigned a value. enter image description here

Dll itself

enter image description here

Code example

 <UserControl x:Class="ASAMWPFElements.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:ASAMWPFElements" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="47*"/> <RowDefinition Height="253*"/> </Grid.RowDefinitions> <Button x:Name="button1" Content="Button" HorizontalAlignment="Left" Margin="33,123,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75"/> <ComboBox x:Name="comboBox" HorizontalAlignment="Left" Margin="78,20,0,0" VerticalAlignment="Top" Width="120"/> <Button x:Name="button" Content="Button" HorizontalAlignment="Left" Height="62" Margin="10,23,0,0" Grid.Row="1" VerticalAlignment="Top" Width="142"/> </Grid> </UserControl> 
  • one
    PresentationCore, PresentationFramework and WindowsBase added? - VladD
  • yes all these libraries are already connected - SergD29
  • Then it is not clear. Maybe attach a code explaining the problem? - VladD
  • He still gives me an error on UserControl11 (with two 1) after the build, although it works before it, here’s a similar way to add c-sharpcorner.com/UploadFile/dpatra/... I only have WPF user element library - SergD29

2 answers 2

The problem was in different versions of .net programs and libraries.

    Inside the project? If my memory does not change, you need to right-click on the project. Select add references. And there will be several bookmarks. - selection from the reference file (usually this item is clicked) - from the site - from its own project (this item is needed)

    • I similarly add c-sharpcorner.com/UploadFile/dpatra/ ... but after the main project is assembled, the link is identified by an exclamation mark and elementHost to become empty still gives an error on UserControl11 - SergD29
    • Is it compiled at all? Maybe the compilation order is broken? For example, the project is not compiled, as there is no. And the second is compiled. Is that possible? - hitcode 4:03 pm