为什么 Interop.WMPLib 在发布模式下无法加载程序集,但在调试模式下可以工作?
我已将 Windows Media Player com 控件添加到我的工具箱中,然后在调试模式下在窗体上成功使用该控件。
但是,当我尝试在发布模式下运行应用程序时,会出现错误...
无法加载文件或程序集 '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
我缺少什么?
I have added the Windows Media Player com control into my toolbox and then used the control successfully on a Form in Debug mode.
However, when I try running the application in Release mode it errors with...
Could not load file or assembly
'Interop.WMPLib, ... or one of its
dependecies. An attempt was made to
load a program with an incorrect
format.
Through some tracing I've established that the error occurs not when creating the control but on the EndInit method.
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
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您更改了调试配置中的平台目标设置。可能是几周前,甚至可能是在 Visual Studio 的早期版本中。但在Release配置中没有改变它。它是特定于配置的设置之一。
You changed the Platform target setting in the Debug configuration. Possibly weeks ago, maybe even in a previous version of Visual Studio. But didn't change it in the Release configuration. It is one of the settings that is configuration specific.
我遇到了同样的问题,发现构建后只有一个程序集(AxInterop.WMPLib.dll)被复制到 Bebug/Release 文件夹中。 Interop.WMPLib.dll 丢失,当我手动复制它时,它当然会运行。现在我正在寻找一种方法来手动复制它(在 csproj 文件中)或寻找其他方法......
I had the same problem and found out that only one assembly (AxInterop.WMPLib.dll) was copied to the Bebug/ Release folder after build. Interop.WMPLib.dll is missing, when i copy it manually of course it runs. Now im looking for a way to either manually copy it (within the csproj file) or find another way...