Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When I try to load an existing and working UserControl in my WPF-project I allways get following error message:

Unable to load the metadata for assembly 'LowLightGrab'. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545. The following error was encountered during load: Could not load file or assembly 'LowLightGrab, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. c:\temp\WpfApplication1LL_Neu\WpfApplication1LL_Neu\MainWindow.xaml

This UserControl 'LowLightGrab' is in a local path as the WPF-project.

My XAML-code is:
XML
<Window x:Class="WpfApplication1LL_Neu.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:lowLightGrab="clr-namespace:LowLightGrab;assembly=LowLightGrab"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <WindowsFormsHost>
            <lowLightGrab:UserControl1/>
        </WindowsFormsHost>
    </Grid>
</Window>



What goes wrong here?
Thanks!
Posted
Comments
TheRealSteveJudge 21-Jan-15 5:46am    
Maybe the dll was blocked by the operating system.
You can check it like this:
Right click on the dll in explorer.
If you see a button called "Unblock" in the dll's properties
you must unblock this dll by clicking this button.
Member 10894922 23-Jan-15 4:38am    
I checked this allready but there is no "unblock" button in the dll's properties.

1 solution

why are you using WindowsFormsHost to load WPF usercontrol?
Looks like you are trying to do as like example available in this link[^]

If you trying to load WPF UserControl no need to use WindowsFormHost.

XML
<Window x:Class="WpfApplication1LL_Neu.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:lowLightGrab="clr-namespace:LowLightGrab;assembly=LowLightGrab"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
            <lowLightGrab:UserControl1/>

    </Grid>
</Window>


the above code is enough If the lowlightgrab:usercontrol1 is a WPF UserControl
 
Share this answer
 
v2
Comments
Member 10894922 23-Jan-15 4:54am    
It is a WindowsForms UserControl which I like to load in my WPF application. I think therefore I need to use the WindowsFormsHost in the XAML.
Gold$Coin 26-Jan-15 22:23pm    
ok got it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900