Public Sub DestroyAndAddReader() Dim n_Left, n_Top, n_Width, n_Height n_Left = DocProcess_Main.AxAcroPDF1.Left n_Top = DocProcess_Main.AxAcroPDF1.Top n_Width = DocProcess_Main.AxAcroPDF1.Width n_Height = DocProcess_Main.AxAcroPDF1.Height DocProcess_Main.Controls.Remove(DocProcess_Main.AxAcroPDF1) Dim o_PDFReader As New FoxitReaderOCX 'Dim f As System.Reflection.FieldInfo 'f = GetType(AxHost).GetField("licenseKey", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance) 'f.SetValue(o_PDFReader, "gnvlslnjskvlmlgnnimh") DocProcess_Main.Controls.Add(o_PDFReader) ' throughs error as described below o_PDFReader.Name = "AxAcroPDF1" o_PDFReader.Location = New Point(n_Left, n_Top) o_PDFReader.Size = New Size(n_Width, n_Height) o_PDFReader.Show() 'o_PDFReader = New FoxitReaderOCX 'DocProcess_Main.Controls.Add(FoxitReaderOCX) 'DocProcess_Main.AxAcroPDF1.Name = "AxAcroPDF1" 'DocProcess_Main.AxAcroPDF1.Location = New(Point(n_Left, n_Top)) 'DocProcess_Main.AxAcroPDF1.Size = New Size(n_Width, n_Height) 'DocProcess_Main.AxAcroPDF1.Visible = True 'o_PDFReader = New FoxitReaderOCX 'o_PDFReader.Name = "AxAcroPDF1" 'o_PDFReader.Location = New Point(n_Left, n_Top) 'o_PDFReader.Size = New Size(n_Width, n_Height) 'DocProcess_Main.Controls.Add(o_PDFReader) 'DocProcess_Main.AxAcroPDF1.Visible = True End SubThe error thrown is:
Unable to cast COM object of type 'FOXITREADEROCXLib.FoxitReaderOCXClass' to class type 'System.Windows.Forms.Control'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.