Exception.InnerException in vb.net

0

This is my first time making a program using visual basic language. I thought my project is running smooth because every time I debug using visual studio the program is ok so I didn't mind checking the .exe file of the program but today I've found this error in the .exe file of the program

An error occured creating the form. See Exception.InnerException for details. The Error is: Could not load file or assembly 'AxInterop.WMPLib.Version=1.0.0.0 Culture=neutral. PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified

I don't understand why the program is running good in visual studio. but has errors in .exe

Here is the code of the form that has error

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
vb.net
asked on Stack Overflow Oct 15, 2013 by Jay • edited Feb 12, 2014 by rene

2 Answers

0

Ok. Make sure that axinterop.dll is present on the directory that the solution file refers to, before compiling. Depending on which OS you have, will depend on how Visual Studio works. The Exception only triggers on a runtime error occurrence. And also, the compiled .exe file, has to be with the .pdb file and the .config file. Otherwise, it would not work. If all else fails, then reboot your device, and if it still fails after that, then it might be a complete internal runtime error.

answered on Stack Overflow Mar 27, 2020 by Megaplasmoid
-1

Make sure that the axinterop dll is present in the application folder. To me it sounds like you only copied the executable from you bin folder.

answered on Stack Overflow Oct 15, 2013 by WozzeC

User contributions licensed under CC BY-SA 3.0