Com Error

Add-in Express™ Support Service
That's what is more important than anything else

Com Error
 
SSL




Posts: 178
Joined: 2014-01-05
  Public Overrides Sub ProcessReply(response As Object, e As ADXCancelEventArgs)

        Dim currentExplorer As Outlook._Explorer = DirectCast(Solution_Outlook.addinmodule.currentinstance.OutlookApp.ActiveExplorer, Outlook.Explorer)

        If currentExplorer Is Nothing Then
            Exit Sub
        Else
           
            If Not response Is Nothing Then
                e.Cancel = True

                Dim ProjectEmailProperty As String = Nothing
                Dim OriginalEmail As Outlook.MailItem = Nothing
                Dim unk As IntPtr = IntPtr.Zero

                unk = Marshal.GetIUnknownForObject(Me.ItemObj)
                Dim original As Object = Marshal.GetObjectForIUnknown(unk)

                Try
                    OriginalEmail = TryCast(original, Outlook.MailItem)

                    ProjectEmailProperty = modEmail.GetisProjectEMailUserMailProperties(OriginalEmail)

                    If ProjectEmailProperty = "True" And fnGetProjectNoUserProperty(myProjectNo, OriginalEmail) <> Nothing Then

                        SetisprojectEmail(True)
                        SetisReply(True)
                        SetisReplyAll(False)
                        SetisForward(False)
                        SetisNewEmail(False)
                        SetisInboxAttachmentEmail(False)
                        SetisContactEmail(False)
                        SetProjectEmailProjectNumber(fnGetProjectNoUserProperty(myProjectNo, OriginalEmail))
                        SetProjectFileRef(fnGetProjectFileRefUserProperty(myProjectFileRef, OriginalEmail))
                        e.Cancel = False
                        'modEmail.ReplyEMail()

                    ElseIf ProjectEmailProperty = "False" And fnGetProjectNoUserProperty(myProjectNo, OriginalEmail) = Nothing Then

                        'clear Project Number
                        SetProjectEmailProjectNumber(Nothing)
                        SetisprojectEmail(False)
                        SetisReply(False)
                        SetisReplyAll(False)
                        SetisForward(False)
                        SetisNewEmail(False)
                        SetisContactEmail(False)
                        SetisInboxAttachmentEmail(False)
                        SetEmailRef(Nothing)
                        SetProjectFileRef(Nothing)
                        e.Cancel = False
                        'modEmail.ReplyEMail()
                    Else
                        e.Cancel = True

                        DevComponents.DotNetBar.MessageBoxEx.Show("Cannot Reply to this email as it has no Project Number assigned or it isn't marked as Personal", "Reply Email", MessageBoxButtons.OK)
                        Exit Sub
                    End If

                Finally
                    ' Marshal.Release(unk)
                    If Me.ItemObj IsNot Nothing Then
                        Marshal.ReleaseComObject(Me.ItemObj)
                    End If
                    If original IsNot Nothing Then
                        Marshal.ReleaseComObject(original)
                    End If
                    If OriginalEmail IsNot Nothing Then
                        Marshal.ReleaseComObject(OriginalEmail)
                    End If
                End Try
            End If
        End If


unk = Marshal.GetIUnknownForObject(Me.ItemObj)




"COM object that has been separated from its underlying RCW cannot be used." On the above line, any thoughts?
Posted 07 Oct, 2015 19:48:24 Top
Andrei Smolin


Add-in Express team


Posts: 18810
Joined: 2006-05-11
Hello Tom,

SSL writes:
Marshal.ReleaseComObject(Me.ItemObj)


Could you please comment out such lines in that class?

SSL writes:
unk = Marshal.GetIUnknownForObject(Me.ItemObj)
Dim original As Object = Marshal.GetObjectForIUnknown(unk)


Could you please explain why do you need this? I suppose there are other ways...


Andrei Smolin
Add-in Express Team Leader
Posted 08 Oct, 2015 01:27:08 Top
SSL




Posts: 178
Joined: 2014-01-05
Hi Andrei,

I tried what you suggested, it didn't make any difference.

On Reply, Reply All and Forward, I need to pass certain user properties from original email to new one, whether it be On Reply, Reply All and Forward from Explorer or Inspector.

The error only appears on first use of any of the buttons.

Regards,

Tom
Posted 08 Oct, 2015 05:02:46 Top
SSL




Posts: 178
Joined: 2014-01-05
Hi Andrei,

Actually the error only appears on first use of Inspector Reply, ReplyAll, Forward.

Any thoughts?

Regards,
Tom
Posted 09 Oct, 2015 05:07:41 Top
Andrei Smolin


Add-in Express team


Posts: 18810
Joined: 2006-05-11
Hello Tom,

Could you please send me a minimal project reproducing this? Also, you've missed this question:

SSL writes:
unk = Marshal.GetIUnknownForObject(Me.ItemObj)
Dim original As Object = Marshal.GetObjectForIUnknown(unk)


Could you please explain why do you need this? I suppose there are other ways...


Andrei Smolin
Add-in Express Team Leader
Posted 12 Oct, 2015 02:32:37 Top