I'm experiencing a strange problem where exporting a crystal report causes problems for displaying a MAPI address book. These are two completely unrelated tasks and I don't understand how one affects the other.
This is an example of exporting the report:
Using rpt As New TestReport rpt.ExportToStream(ExportFormatType.PortableDocFormat) End Using
This is an example of showing the MAPI address book:
Dim msg As New AxMSMAPI.AxMAPIMessages Dim sess As New AxMSMAPI.AxMAPISession Dim f As System.Reflection.FieldInfo Const MAPI_LICENSE As String = "mgkgtgnnmnmninigthkgogggvmkhinjggnvm" f = GetType(AxHost).GetField("licenseKey", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance) f.SetValue(msg, MAPI_LICENSE) f.SetValue(sess, MAPI_LICENSE) sess.Parent = Me msg.Parent = Me sess.DownLoadMail = False sess.LogonUI = True sess.SignOn() sess.NewSession = True msg.SessionID = sess.SessionID msg.Compose() msg.Action = MSMAPI.MessagesActionConstants.mapShowAddressBook sess.SignOff()
One strange thing is that if I show the MAPI address book first, then both exporting the crystal report and displaying the MAPI address book work for the remainder of the life of the program. If I export first, the MAPI address book does not work for the remainder of the life of the program.
The exception that gets thrown is at the following line as "Unspecified Failure has occurred" with error code "-2146796286"
msg.Action = MSMAPI.MessagesActionConstants.mapShowAddressBook
Our project is using .NET 4 Full, along with Crystal Reports 13.0.5.x, and we have also tested Crystal 13.0.6.x with the same results.