christosh
christosh

Reputation: 193

Windows Form C# cannot find AXWMPlib

I have created a windows form application in c# which loads video from hard disk and display them in the form using windows media player. After a 2-3 pc restarts when I am operning my project in visual studio I am receiving the following message and I can't enter to the designer:

enter image description here

Any idea how can I overcome this burden? Can I program my form elments without the designer? The weird is that windows media player is working fine when I am running my project but it just dont let me change the design of the form!

Upvotes: 1

Views: 1734

Answers (3)

Mabito
Mabito

Reputation: 61

There are two ways to add Windows Media Player to a WinForms project. However, the second method didn’t work for me:

  1. Using the Toolbox:

    • Right-click the Toolbox in Visual Studio and select Choose Items.
    • In the COM tab, locate and add the Windows Media Player component.
    • Drag the component onto the WinForm. This will automatically add the required references to the project.
  2. Manually Adding a Reference (did not work in my case):

    • Right-click the References folder in the project tree and select Add Reference.
    • Go to the COM tab, find and select Windows Media Player, and add it to the project.

Upvotes: 0

György Kőszeg
György Kőszeg

Reputation: 18013

  • See the references of your project. Make sure there are no references with exclamation mark
  • Make sure that the AxWMPLIB ActiveX component is registered in Windows. If not, look for the corresponding .dll or .ocx files and register them with by the regsvr32 command.
  • If your project can be compiled, try to close and re-open the designer. It is a common issue in Visual Studio.
  • It seems that you use an AnyCPU build. The Visual Studio is executed in a 32-bit process (devenv.exe) even in a 64-bit Windows. It means that the designer is executed in a 32 bit environment as well. Sometimes this can lead to such errors if you use 3rd party components. Try to add the x86 configuration in the Configuration Manager, make a new build and try to open the designer afterwards. At the end you can build the AnyCPU version of you app, of course.
  • If nothing helps open the *.Designer.cs and configure your form manually...

Upvotes: 1

Timothy Groote
Timothy Groote

Reputation: 8643

You can check whether code is being executed at design time like this :

if(System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
//... do not execute the code that will crash at design time.

Upvotes: 1

Related Questions