Cannot create an instance of "VideoCaptureElement".

Jan 22, 2015 at 1:22 PM

I'm trying to develop an UserControl to make pictures using de webcam and WPF MediaKit. But when I add the VideoCaptureElement I get this error:

Could not load file or assembly 'DirectShowLib-2005, Version=, Culture=neutral, PublicKeyToken=67e7b740cdfc2d3f' or one of its dependencies. The system cannot find the file specified.

I have added DirectShowLib-2005.dll and WPFMediaKit.dll to my VS2012 project and add both references. This is my XAML code:
<UserControl x:Class="MyProject.Controls.ImageCaptureControl"
             d:DesignHeight="400" d:DesignWidth="700" Loaded="UserControl_Loaded">
        <Canvas Width="320" Height="180" Background="Black">
            <WPFMediaKit:VideoCaptureElement x:Name="VideoCaptureElement" Width="320" Height="180" DesiredPixelWidth="320" DesiredPixelHeight="180" FPS="30"/>
In the visual representation of the control I can read this:

Cannot create an instance of "VideoCaptureElement".

Do you know why is happening?

Thank you,
Jan 28, 2015 at 11:03 AM
I have discovered the reason of the problem. In design view I get the same error, but I managed to make it run: I changed the Target platform from Any CPU to x86.
Marked as answer by Jon123 on 1/28/2015 at 4:03 AM
Sep 21, 2016 at 1:37 PM
I had the exact problem
I beat my head against the wall trying to find an alternate way to capture my webcam and every method I tried has a problem of some kind.
Finally I went back to troubleshoot the mediakit capture and realized that although I get errors in the designer- cant find DirectShowLib, it actually works fine when I run it.
I also tried changing to x386, and at one point it seemed to work but the problem returned and I haven't ben able to remedy it.
I would think that if my project references the media kit project and that project has reference to Direct Show, that I shouldn't need it in my project.
-Doesn't work with or without it.
I also tried referencing the mediakit using the compiled DLL- no difference.