5

I'm trying to import WMPLib but Visual Studio but it's giving message Type or Namespace name 'WMPLib' could not be found. I also tried using System.Windows.Media but again for Media it's giving same message. I tried adding in toolbox Windows Media Player from

Choose Tool Box Items->Com Components->Windows Media Player

But this is not working.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
fhulprogrammer
  • 599
  • 2
  • 7
  • 16

1 Answers1

9

To create the Windows Media Player control programmatically, you must first add a reference to wmp.dll, which is found in the \Windows\system32 folder. Adding this reference creates WMPLib.dll in your project folder, and a reference to WMPLib appears in Solution Explorer.

The following Link will help you.

Creating the Windows Media Player Control Programmatically

Gehan Fernando
  • 1,221
  • 13
  • 24
  • 1
    I tried it but it's not working. Still same message. – fhulprogrammer Mar 18 '15 at 16:15
  • Can you post the complete error message, coz the above solution worked for us. – Gehan Fernando Mar 18 '15 at 16:32
  • I'm developing my project in Visual studio 2012. When I use code `using WMPLib;` it shows following error `Error 1 The type or namespace name 'WMPLib' could not be found (are you missing a using directive or an assembly reference?) E:\c#.net\new_project\FirstWinService\FirstWinService\SchedulerService.cs 10 7 FirstWinService ` – fhulprogrammer Mar 18 '15 at 16:51
  • 1
    You also need to add `using WMPLib;` at the top of your file. – Christian Lundahl Jun 21 '16 at 01:34