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?
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