这是我第一次使用 Visual Basic 语言编写程序。我以为我的项目运行顺利,因为每次我使用 Visual Studio 调试程序都可以,所以我不介意检查程序的 .exe 文件,但今天我在程序的 .exe 文件中发现了这个错误
创建表单时发生错误。有关详细信息,请参阅 Exception.InnerException。错误是:无法加载文件或程序集'AxInterop.WMPLib.Version=1.0.0.0 Culture=neutral。PublicKeyToken=null' 或其依赖项之一。该系统找不到指定的文件
我不明白为什么该程序在 Visual Studio 中运行良好。但在.exe中有错误
这是有错误的表单的代码
Public Class formVideo
Private Sub TestForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2,
(Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2)
Call Disable(Me)
End Sub
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Integer, ByVal revert As Integer) As Integer
Private Declare Function EnableMenuItem Lib "user32" (ByVal menu As Integer, ByVal ideEnableItem As Integer, ByVal enable As Integer) As Integer
Private Const SC_CLOSE As Integer = &HF060
Private Const MF_BYCOMMAND As Integer = &H0
Private Const MF_GRAYED As Integer = &H1
Private Const MF_ENABLED As Integer = &H0
Public Shared Sub Disable(ByVal form As System.Windows.Forms.Form)
' The return value specifies the previous state of the menu item (it is either
' MF_ENABLED or MF_GRAYED). 0xFFFFFFFF indicates that the menu item does not exist.
Select Case EnableMenuItem(GetSystemMenu(form.Handle.ToInt32, 0), SC_CLOSE, MF_BYCOMMAND Or MF_GRAYED)
Case MF_ENABLED
Case MF_GRAYED
Case &HFFFFFFFF
Throw New Exception("The Close menu item does not exist.")
Case Else
End Select
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Call Disable(Me)
End Sub
Private Sub btnMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMenu.Click
Me.Close()
formMenu.Show()
End Sub
Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click
mpVideo.Ctlcontrols.play()
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
mpVideo.Ctlcontrols.pause()
End Sub
Private Sub btnCPU_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCPU.Click
mpVideo.URL = "Resources\See How the CPU Works In One Lesson.avi"
End Sub
Private Sub btnMobo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMobo.Click
mpVideo.URL = "Resources\Understanding your motherboard.avi"
End Sub
Private Sub btnHDD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHDD.Click
mpVideo.URL = "Resources\What is a Hard Drive_ (HDD vs SSD_) - Computer Basics.avi"
End Sub
Private Sub btnRam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRam.Click
mpVideo.URL = "Resources\What is RAM_ - Computer Basics.avi"
End Sub
Private Sub btnPSU_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPSU.Click
mpVideo.URL = "Resources\Testing the PC's PSU.avi"
End Sub
Private Sub btnVGA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVGA.Click
mpVideo.URL = "Resources\What is a GPU_ - Computer Basics.avi"
End Sub
Private Sub btnCooling_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCooling.Click
mpVideo.URL = "Resources\A Beginner's Guide to Water Cooling Your Computer.avi"
End Sub
Private Sub btnExtensions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExtensions.Click
mpVideo.URL = "Resources\Peripheral - Wiki Article.avi"
End Sub
Private Sub mpVideo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mpVideo.Enter
mpVideo.stretchToFit = True
End Sub
Private Sub btnFF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFF.Click
mpVideo.Ctlcontrols.fastForward()
End Sub
Private Sub btnRewind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRewind.Click
mpVideo.Ctlcontrols.fastReverse()
End Sub
End Class