Reputation: 492
I am trying to add a Windows Media Player object to my Windows form but it pops out an error:
Failed to create compopnent 'AxHost'. The error message follows:
'System.Reflection.ReflectionTypeLoadException: Unable to load
one or more of the requested types. Retrieve the LoaderExceptions
property for more information.
at
System.Windows.Forms.Design.DocumentDesigner.AxToolboxItem.
CreateComponentsCore(IDesignerHost host)
at
System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost
host, IDictionary defaultValues)
at
System.Drawing.Design.ToolboxItem.CreateComponents(IDesignerHost
host, IDictionary defaultValues)
at
System.Windows.Forms.Design.OleDragDropHandler.CreateTool(ToolboxItem
tool, Control parent, int32 x, int32 width, int32
height, Boolean hasLocation, Boolean hasSize,
ToolboxSnapDragDropEventArgs e)'
However, if I were to create a new project and add the Windows Media Player, it works perfectly fine.
I have tried some solutions online such as adding the Windows Media Player while the new project (With Windows Media Player) is open, adding the existing form to the project etc. but to no avail.
Is there anything that I have done wrongly?
Upvotes: 5
Views: 4233
Reputation: 216
This is how I solved the problem under VB, Since windows media player is based on x86 binaries by default, the following trick is used to use it under x64 application:
Upvotes: 0
Reputation: 323
For Noobs Like Me Remove 'AxWMPLib',"WMPLib" reference from references and also "Windows Media Player" from ToolBox then Close Project (Visual Studio) Then Open Project Again then go to Properties -> Compile -> Target CPU = x86 and Platform = x86 Then Add Windows Media Player Thru The ToolBox then Rebuild The Project. Add Media Player Control using the toolbox via Drag and Drop.... Problem Solve ^_^
Upvotes: 1
Reputation: 163
I solved this problem by removing 'AxWMPLib',"WMPLib" reference from references. Then. Again adding Media Player On the Form.
Upvotes: 6
Reputation: 61
Not sure if you're still looking for a solution for this, but maybe this will help someone else. I was just having the same issue with trying to embed a different COM object.
After banging my head against the wall for a couple hours, I realized that in the project Properties -> Build -> Platform Target was set to x64 (because I was playing with something a couple of months back), and many of these old COM assemblies target 32 bit systems. Anyways, switching my Platform target to "Any CPU" solved the issue.
Nik
Upvotes: 6