Home Can't find the reference to a library
Reply: 0

Can't find the reference to a library

user2541
1#
user2541 Published in April 22, 2018, 12:54 am

Trying to shadow copy file from path A to Path B but it keep throwing me error message

{"Could not load file or assembly 'AlphaVSS.x64, Version=1.4.0.0, Culture=neutral, PublicKeyToken=959d3993561034e3' or one of its dependencies. An attempt was made to load a program with an incorrect format."}

Code i try with it

  Public Sub copyFile(baza As String, destination As String)

        If IO.File.Exists(baza) Then

            Dim myFileInfo As FileInfo
            myFileInfo = New FileInfo(baza)

            Dim _volume As String = myFileInfo.Directory.Root.Name

            Dim _vssImplementation As IVssImplementation = VssUtils.LoadImplementation()
            Dim _backup As IVssBackupComponents = _vssImplementation.CreateVssBackupComponents()

            _backup.InitializeForBackup(Nothing)

            _backup.GatherWriterMetadata()

            _backup.SetContext(VssVolumeSnapshotAttributes.Persistent Or VssVolumeSnapshotAttributes.NoAutoRelease)
            _backup.SetBackupState(False, True, Alphaleonis.Win32.Vss.VssBackupType.Full, False)

            Dim MyGuid01 As Guid = _backup.StartSnapshotSet()
            Dim MyGuid02 As Guid = _backup.AddToSnapshotSet(_volume, Guid.Empty)

            _backup.PrepareForBackup()
            _backup.DoSnapshotSet()

            _backup.ExposeSnapshot(MyGuid02, Nothing, VssVolumeSnapshotAttributes.ExposedLocally, "L:")

            Dim sVSSFile2 As String = baza.Replace(_volume, "L:\")

            If (File.Exists(sVSSFile2)) Then
                System.IO.File.Copy(sVSSFile2, destination + "\" + System.IO.Path.GetFileName(baza), True)

                For Each prop As VssSnapshotProperties In _backup.QuerySnapshots
                    If (prop.ExposedName = "L:\") Then
                        Console.WriteLine("File found !")
                        _backup.DeleteSnapshot(prop.SnapshotId, True)
                    End If
                Next

                _backup = Nothing

                Console.WriteLine("File copied")

            Else

                Console.WriteLine("------------------------------------------")
                Console.WriteLine("File not exist: " + baza)

            End If
        End If
    End Sub

I have the VSS nuget package and references

It throws error on line

Dim _vssImplementation As IVssImplementation = VssUtils.LoadImplementation()
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305846 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO