Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface not supported Exception while using the set operaiton in IMAPI #441

Closed
BluerGost opened this issue Feb 27, 2024 · 2 comments
Closed

Comments

@BluerGost
Copy link

I have attached the code I am using below. But during the [ iFileSystemImage.MultisessionInterfaces = iDiscFormat2Data.MultisessionInterfaces;] statement the code throws exception [Interface not supported]. Other properties also throw the same error during the [set].

public MediaInformation DetectMedia(IDiscRecorder2 discRecorder)
{
    MsftFileSystemImage fileSystemImage = new MsftFileSystemImage();
    MsftDiscFormat2Data discFormatData  = new MsftDiscFormat2Data();

    try
    {
        var iFileSystemImage = fileSystemImage as IFileSystemImage;
        var iDiscFormat2Data = discFormatData as IDiscFormat2Data;

        if (iFileSystemImage == null) 
        {
            Console.WriteLine($"Could not cast to IFileSystemImage");
            return null;
        } 

        if (iDiscFormat2Data == null) 
        {
            Console.WriteLine($"Could not cast to IDiscFormat2Data");
            return null;
        }

        if (!iDiscFormat2Data.IsCurrentMediaSupported(discRecorder))
        {
            Console.WriteLine("Current media is not supported");
            return null;
        }

        var mediaInformation = new MediaInformation();

        // Get the media type in the recorder
        iDiscFormat2Data.Recorder = discRecorder;
        var mediaType = (iDiscFormat2Data).CurrentPhysicalMediaType;
        var mediaTypeString = GetMediaTypeString(mediaType);
        mediaInformation.MediaType = mediaTypeString;
        Console.WriteLine($"Media Type : 「{mediaTypeString}」");

        // Create a file system and select media type
        iFileSystemImage.ChooseImageDefaultsForMediaType(mediaType);

        // See if there are other recored sessions on the disc
        if (!iDiscFormat2Data.MediaHeuristicallyBlank)
        {
            iFileSystemImage.MultisessionInterfaces = iDiscFormat2Data.MultisessionInterfaces;
            iFileSystemImage.ImportFileSystem();
        }

        var fileMediaBlocks = iFileSystemImage.FreeMediaBlocks;
        var totalDiskSize = 2048 * fileMediaBlocks;
        mediaInformation.TotalDiskSize = totalDiskSize;
        Console.WriteLine($"Total Disk Size : 「{totalDiskSize}」");

        return mediaInformation;
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
        return null;
    }
    finally
    {
        if (fileSystemImage != null)
        {
            Marshal.ReleaseComObject(fileSystemImage);
        }

        if (discFormatData != null)
        {
            Marshal.ReleaseComObject(discFormatData);
        }
    }
}
@dahall
Copy link
Owner

dahall commented Mar 25, 2024

I think I've found the issue with setting IFileSystemImage.MultisessionInterfaces. Which other properties are failing settting?

dahall added a commit that referenced this issue Mar 28, 2024
@dahall
Copy link
Owner

dahall commented Mar 28, 2024

Fixed for 4.0 build. Release coming soon.

@dahall dahall closed this as completed Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants