This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

COM object that has been separated from its underlying RCW cannot be used.

Hi,
Below is my code.

#Region "Drag-drop Implementation"
    Friend Class DragDropData
        Public Pidl As Aurigma.GraphicsMill.WinControls.Pidl

        Public Sub New(ByVal itemPidl As Aurigma.GraphicsMill.WinControls.Pidl)
            Pidl = itemPidl
        End Sub
    End Class

    Private Sub ThumbNailList_ItemDrag(ByVal sender As Object, ByVal e As Aurigma.GraphicsMill.WinControls.ItemDragEventArgs) Handles ThumbnailListView1.ItemDrag
        If e.MouseButton = Windows.Forms.MouseButtons.Left Then
            Dim item As Aurigma.GraphicsMill.WinControls.ThumbnailListItem = DirectCast(e.Item, Aurigma.GraphicsMill.WinControls.ThumbnailListItem)
            DoDragDrop(New DragDropData(item.Pidl), DragDropEffects.Move)
        End If
    End Sub

    Private Sub BitmapViewerDragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles BitmapViewerMainView.DragEnter
        If e.Data.GetData(GetType(DragDropData)) IsNot Nothing Then
            e.Effect = DragDropEffects.Move
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub

    Private Sub BitmapViewerDragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles BitmapViewerMainView.DragDrop
        Dim myData As DragDropData = DirectCast(e.Data.GetData(GetType(DragDropData)), DragDropData)

        If myData IsNot Nothing Then
            Dim stream As System.IO.Stream = myData.Pidl.Stream
            Dim UserImage As New Aurigma.GraphicsMill.Bitmap(OpenedImage)
            Dim MaskImage As New Aurigma.GraphicsMill.Bitmap(stream)
            Dim resultImage As New Aurigma.GraphicsMill.Bitmap(UserImage.Width, UserImage.Height, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb)

            Dim rf As New RectangleF(0, 0, UserImage.Width, UserImage.Height)
            Using combiner As New Combiner(UserImage, rf, rf, CombineMode.Copy, 1, InterpolationMode.HighQuality)
                combiner.ApplyMaskTransform(resultImage, MaskImage, BitmapViewerMainView.Bitmap)
            End Using

            stream.Close()
        End If

    End Sub
#End Region


For the 1st few time, it runs smoothly, but after that the Error: "COM object that has been separated from its underlying RCW cannot be used." appear.

System.Runtime.InteropServices.InvalidComObjectException was unhandled
Message="COM object that has been separated from its underlying RCW cannot be used."
Source="Aurigma.GraphicsMill.WinControls"
StackTrace:
at Aurigma.IStream.Commit(STGC grfCommitFlags)
at Aurigma.ComStreamWrapper.Close()
at Aurigma.ComStreamWrapper.Finalize()

Please help. Thanks in advance.
Hello,

I have tried to reproduce the issue, but without any success. Could you submit case with whole test project for debug with a short description of the desired functionality?
Hi Alex,
Thanks for the reply. The problem already solved.
Thank you.
Hi,

Great news! $)