I am working on add-in for Solidworks.In this Add-in, An AviFile.dll library is used to create a video from bitmap images. While creating a videostream object, an System.AccessViolation exception is thrown. The code snippet is shared.
string videosFilePath = _flowPlusPath + "\videos";
Bitmap bitmap1 = (Bitmap)Image.FromFile(imageFilePaths[0]);
string[] directories = _flowPlusPath.Split(Path.DirectorySeparatorChar);
string prefix = directories [directories.Length-2]+" ("+ directories[directories.Length - 1]+") " + "-";
int index = SolverHelper.GetStartFileIndex(videosFilePath, prefix) + 1;
string videoName = Path.Combine(videosFilePath, prefix + index.ToString("000") + ".avi");
AviManager aviManager = new AviManager(videoName, false); ;
Avi.AVICOMPRESSOPTIONS opts = SetCompressOptions();
try
{
VideoStream aviStream = aviManager.AddVideoStream(true, 5, bitmap1); // Here exception is thrown
PopulateVideoStream(aviStream, imageFilePaths);
}
I checked the bitmap1 parameter passed to this. It is not null. Also note that the same code is used in another standalone application for video making but there is no issue observed.
Earlier we had Solidworks 2021 version and there was no exception issue. This is observed when we upgraded to Solidworks 2023 version.
Please suggest the possible reasons for this issue.
Vaibhav Yadav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.