Here’s the scenario where the issue occurs: we have a Reload UI button that, when clicked, closes the currently active form and reinitializes the PDF Editor form. This form is then added back into a split container and displayed. However, when the user tries to save the document after this process, the exception is thrown.
Exception:
Catastrophic failure (0x8000FFFF (E_UNEXPECTED))
at PDFXEdit.IPXV_Document.Save(Object pDest, Int32 nFlags, IProgressMon pProgress, IPXV_ExportConverter pDestConv, ICab pDestConvParams, IAFS_FileSys pDestFS, ICab pAdvancedParams, UInt64 hWndParent)
at TestAXControl.FrmPdfEditor.button1_Click(Object sender, EventArgs e) in C:\Users\sbala\source\repos\TestAXControl\TestAXControl\FrmPdfEditor.cs:line 59
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)
Code: Form1(MainForm)
Code: Select all
namespace TestAXControl
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Initialize();
}
public void Initialize()
{
FrmPdfEditor pdfForm = new FrmPdfEditor()
{
TopLevel = false,
FormBorderStyle = FormBorderStyle.None,
Dock = DockStyle.Fill,
};
this.splitContainer1.Panel2.Controls.Add(pdfForm);
pdfForm.Show();
}
private void button1_Click(object sender, EventArgs e)
{
this.ReloadUiInternal();
}
private void ReloadUiInternal()
{
var pdfForm = Application.OpenForms.OfType<FrmPdfEditor>().FirstOrDefault();
pdfForm?.Dispose();
// Clear dynamic UI panels
this.splitContainer1.Panel2.Controls.Clear();
// Re-run initialization logic
this.Initialize();
this.Focus();
}
}
}
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TestAXControl
{
public partial class FrmPdfEditor : Form
{
private int[] nEditorIDS;
public FrmPdfEditor()
{
InitializeComponent();
this.Initialize();
}
public void Initialize()
{
this.axpxV_Control1.SetLicKey(this.GetKeyUnescaped());
this.axpxV_Control1.OpenDocFromPath(@"C:\Users\sbala\source\repos\TestAXControl\TestAXControl\Einstein 5.0-Prod_Installation_Guid.pdf");
}
private void button1_Click(object sender, EventArgs e)
{
this.axpxV_Control1.Doc.Save();
}
public string GetKeyUnescaped()
{
var value = ConfigurationManager.AppSettings["TrackerEditorRegKey"];
if (string.IsNullOrEmpty(value))
{
return string.Empty;
}
return value
.Replace("\\r\\n", System.Environment.NewLine)
.Replace("\\n", "\n")
.Replace("\\r", "\r")
.Replace("\\t", "\t");
}
}
}