C#Windows Media Player AxHost错误:无法创建组件';AxHost';

C#Windows Media Player AxHost错误:无法创建组件';AxHost';,c#,windows,media-player,media,axhost,C#,Windows,Media Player,Media,Axhost,我试图将Windows Media Player对象添加到我的Windows窗体中,但弹出一个错误: 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 prope

我试图将Windows Media Player对象添加到我的Windows窗体中,但弹出一个错误:

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)'
但是,如果我要创建一个新项目并添加Windows Media Player,它的工作效果非常好

我曾尝试过一些在线解决方案,例如在新项目(使用Windows Media Player)打开时添加Windows Media Player,将现有表单添加到项目中等,但都没有效果


有什么是我做错的吗?

不确定您是否仍在寻找解决方案,但这可能会帮助其他人。我只是在尝试嵌入不同的COM对象时遇到了同样的问题

在碰壁几个小时后,我意识到在项目属性->构建->平台目标被设置为x64(因为几个月前我正在玩一些东西),而这些旧的COM组件中有许多是针对32位系统的。无论如何,将我的平台目标切换到“任何CPU”解决了这个问题


Nik

我通过从引用中删除“AxWMPLib”和“WMPLib”引用解决了这个问题。 那么。 再次在表单上添加媒体播放器。

适用于像我这样的Noobs 从引用中删除“AxWMPLib”、“WMPLib”引用,并从工具箱中删除“Windows Media Player”,然后关闭项目(Visual Studio),然后再次打开项目,然后转到属性->编译->目标CPU=x86和平台=x86
通过工具箱添加Windows Media Player,然后重建项目。通过拖放…使用工具箱添加媒体播放器控件。。。。问题解决^ ^

谢谢。这让我走上了正确的方向,但我还必须选中“允许不安全代码”框。