This project is read-only.

ArgumentException when trying to mount VSS volume created with AlphaVSS

Apr 23, 2009 at 3:43 AM
I am working on a project that includes both AlphaVSS and AlphaFS to generate a snapshot of a volume, then expose it as a mount point.

Here is an (abreviated example) of the code I am using to generate the snapshot:
            Guid gSnapshot = Guid.Empty, gSet = Guid.Empty;
                vssBackupComponent = vssImplementation.CreateVssBackupComponents();
                vssBackupComponent.SetBackupState(false, true, type, false);

                using (IVssAsync async = vssBackupComponent.GatherWriterMetadata())
                        { async.Wait(); }

                gSet = vssBackupComponent.StartSnapshotSet();
                gSnapshot = vssBackupComponent.AddToSnapshotSet(DriveLetter, Guid.Empty);

                using (IVssAsync async = vssBackupComponent.PrepareForBackup())
                        { async.Wait(); }
                using (IVssAsync async = vssBackupComponent.DoSnapshotSet())
                        { async.Wait(); }
                using (IVssAsync async = vssBackupComponent.BackupComplete())
                        { async.Wait(); }
            } (...)

And the troublesome block:
                        if(gSnapshot != Guid.Empty)
                            String vol = @"\\?\Volume{" + gSnapshot.ToString() + @"}\";
                            Volume.SetVolumeMountPoint((String)args[0], vol);                     
args being an ArrayList of arguments (at that point, it contains a string with something like @"C:\Backup\".

Any ideas?
Thanks in advance!
Apr 23, 2009 at 4:09 AM
There are a couple of errors here.
First off, there is no volume with the name you specify for the string 'vol' (unless M$ did something wrong in their GUID implementation ;).
The ID of a snapshot is not available as a volume unless exposed. It is however available as a device, which can be retrieved by calling:


This could be used with something like Volume.DefineDosDevice to use the "XP-hack" to expose it as a drive letter.

The better way however, would be calling ExposeSnapshot, i.e. something like:

     vssBackupComponent.ExposeSnapshot(gSnapshot, (String)args[0], VssVolumeSnapshotAttributes.ExposedLocally, dir);

Hope this helps.

Sincerely, Peter.
Apr 23, 2009 at 4:14 AM
Note also that you can use the device name to access the files directly from the snapshot without exposing it as a directory using AlphaFS.

Try for an example: