ManagedDism
ManagedDism copied to clipboard
Commit Image error the value of '102' is not valid for 'value'
When I commit install.wim, it cannot unmount normally
DismApi.UnmountImage(mountedImageInfo.MountPath, commitChanges: true, progressCallback: ImageProgressCallback);
the error is as follows:
System. Argumentoutofrangeexception: the value of '102' is not valid for 'value'. 'value' should be between'minimum'and'maximum'. (Parameter 'value')
When I discard install.wim, it can unmount normally
DismApi.UnmountImage(mountedImageInfo.MountPath, commitChanges: false, progressCallback: ImageProgressCallback);
Does ImageProgressCallback do something special? Is the managed DISM API here on the callstack for the exception?
This line is probably throwing:
MoHelper.ProgressBar.Value = progress.Current;
I'm not sure why but the DISMAPI value for progress.Current is not always 0-100. If you want to safely calculate progress by percent, you'll need to probably use Total and divide by Current?
The documentation doesn't specify what values to expect: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dismprogresscallback?view=windows-11
I didn't fully understand the instructions in the link above. Can you give some examples?
Like this?
MoHelper.ProgressBar.Value = progress.Total / progress.Current;
Like this? If it looks like this, the error is as follows: System.DivideByZeroException: Attempted to divide by zero.
From the above code, you can get a sense of what I want to achieve. I am not sure if the code I wrote is elegant, can you give me an elegant implementation of MountImage or UnMountImage saving method?