Thanks Abhi,
I am hosting the control in the WindowsFormsHost using the WPF user control as you have mentioned. But in the code behind I am creating a private variable _pdfDocument of type the thrid party control [DynamicPDF4Net]. But when I access the method listed in the _pdfDocument an exception is thrown
usercontrol = (DynamicPdfViewer)obj;
usercontrol._pdfDocument.OpenStream((Stream)e.NewValue,"");
InvalidActiveXStateException occurred {"Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown."}.
To resolve this, as there may be chances that control is not properly initialized. I have added the following code for initilization, but again it is throwing OcxState exception
The code snipped is as below
public partial class DynamicPdfViewer : UserControl
{
#region [ Private Variables ]
ceTe.DynamicPDF.AxViewer.Control.DynamicPDFViewerControl _pdfDocument = new DynamicPDFViewerControl();
#endregion
#region [ Constructor ]
public DynamicPdfViewer()
{
InitializeComponent();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DynamicPDFViewer));
((System.ComponentModel.ISupportInitialize)(this._pdfDocument)).BeginInit();
_pdfDocument.SuspendLayout();
_pdfDocument.Dock = System.Windows.Forms.DockStyle.Fill;
_pdfDocument.Enabled = true;
_pdfDocument.Location = new System.Drawing.Point(0, 0);
_pdfDocument.Name = "pdfViewer";
this._pdfDocument.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("this._pdfDocument.OcxState")));
_pdfDocument.Size = new System.Drawing.Size(337, 359);
_pdfDocument.Text = "_pdfDocument";
//_pdfDocument.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_pdfDocument.OcxState")));
_pdfDocument = new ceTe.DynamicPDF.AxViewer.Control.DynamicPDFViewerControl();
((System.ComponentModel.ISupportInitialize)(this._pdfDocument)).BeginInit();
}
Anwarcode, if this helps please login to Mark As Answer. | Alert Moderator