为什么Interop.WMPLib无法在发布模式下加载程序集,但在调试模式下工作?

时间:2011-06-01 22:55:53

标签: visual-studio-2010 controls winforms-interop

我已将Windows Media Player com控件添加到我的工具箱中,然后在调试模式下的Form上成功使用了控件。

但是,当我尝试在发布模式下运行应用程序时,它出现错误...

  

无法加载文件或程序集   'Interop.WMPLib,......或其中一个   依赖条件。试图做到   加载程序不正确   格式。

通过一些跟踪,我已经确定错误不是在创建控件时发生的,而是在EndInit方法上发生的。

Public Sub New

    InitializeComponent() 

    wmp = New AxWMPLib.AxWindowsMediaPlayer()
    wmp.BeginInit()
    wmp.Enabled = True
    wmp.Name = "wmp"
    wmp.OcxState = CType(resources.GetObject("wmp.OcxState"), AxHost.State)
    Me.Controls.Add(wmp)
    Me.Controls.SetChildIndex(wmp, 0)
    wmp.Dock = System.Windows.Forms.DockStyle.Fill
    wmp.EndInit()   ' <<< errors here !

End Sub

我错过了什么?

1 个答案:

答案 0 :(得分:1)

您在Debug配置中更改了Platform目标设置。可能在几周前,甚至可能在以前版本的Visual Studio中。但是在Release配置中没有改变它。这是配置特定的设置之一。