加载互操作时出错.WMPLib Windows MediaPlayer在WPF应用程序

本文关键字:MediaPlayer WPF 应用程序 Windows WMPLib 互操作 出错 加载 | 更新日期: 2023-09-27 18:06:10

Error   1   Unknown build error, 'Cannot resolve dependency to 
assembly 'Interop.WMPLib, Version=1.0.0.0, Culture=neutral PublicKeyToken=null'        
because it has not been preloaded. When using the ReflectionOnly APIs, dependent       
assemblies must be pre-loaded or loaded on demand through the  
ReflectionOnlyAssemblyResolve event. Line 20 Position 14.' 

有什么想法吗,我是否需要包括更多的文件或其他东西

WPF

<Window ...  xmlns:activeXControl="clr-namespace:AxWMPLib;assembly=AxInterop.WMPLib">
<Grid>
     <WindowsFormsHost x:Name="winFormsHost" Grid.Column="1">
         <activeXControl:AxWindowsMediaPlayer x:Name="activeXMediaPlayer"/>
     </WindowsFormsHost>
</Grid>
</Window>

窗口标签故意截断

加载互操作时出错.WMPLib Windows MediaPlayer在WPF应用程序

您应该安装WMP Media Player,如果您已经安装了WMP Media Player,那么在重新启动后卸载它并安装新的WMP Media Player。

  1.COM dll is not registered properly
  2.Because of loading different version of Interop dll(i mean DLL Hell).
  3.Dll not loaded Properly because ofplateform Compatibility 
  or Others.