unable to cast COM object of type "system.__comObject" to interface type 'shell32.shell'

1.1k views Asked by At

I run my project in win 7 and xp, but there is an error message, in this project I use shell32.shell to copy and extract automatic exe file, does shell32.shell not work in windows 7 and xp? if you can, please suggest that sheell32.shell can run

Dim sc As New Shell32.Shell()
Dim pathExeOnServer As String = "\\server\UpdateProgram\"

Try
                If (Not System.IO.Directory.Exists(Path.Combine(Application.StartupPath() & "\RS_Application"))) Then
                    Directory.CreateDirectory(Path.Combine(Application.StartupPath() & "\RS_Application"))
                Else
                    'DO NOTHING
                End If

                Me.Cursor = Cursors.WaitCursor
                File.Copy(Path.Combine(pathExeOnServer, fileName & ".zip"), Path.Combine(Application.StartupPath() & "\RS_Application", fileName & ".zip"), True)
                System.IO.File.Delete(Application.StartupPath() & "\RS_Application\" & fileName & ".exe")
                Dim output As Shell32.Folder = sc.NameSpace(Application.StartupPath() & "\RS_Application")
                Dim input As Shell32.Folder = sc.NameSpace(Application.StartupPath() & "\RS_Application\" & fileName & ".zip")
                output.CopyHere(input.Items, 4)
                Me.Cursor = Cursors.Arrow
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Critical)
            End Try

error message

0

There are 0 answers