Problem creating new PDFControl

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Problem creating new PDFControl

Post by cew »

Hi there,

sometimes the viewer gets in an inconsistant state and all calls to methods fail with an exception, e.g.:

Code: Select all

Der RPC-Server ist nicht verfügbar. (Ausnahme von HRESULT: 0x800706BA)
----- details below -----
ErrorCode = -2147023174
Message = Der RPC-Server ist nicht verfügbar. (Ausnahme von HRESULT: 0x800706BA)
Data = System.Collections.ListDictionaryInternal
InnerException = null
TargetSite = Void GetDocumentsCount(Int32 ByRef)
StackTrace =    bei PDFXCviewAxLib.IPDFXCview2.GetDocumentsCount(Int32& Count)
When catching that exception I would like to create a new instance of the PDFControl within the parent WindowsFormsHost like:

Code: Select all

ViewerHost.Child = null;

PDFViewer = new PDFControl();
PDFViewer.CreateControl();
PDFViewer.Name = "PDFViewer";

ViewerHost.Child = PDFViewer;
But whenb I try to call SetDevInfo, I get the folling System.NullReferenceException:

Code: Select all

bei System.Windows.Forms.AxHost.OleInterfaces.System.Windows.Forms.UnsafeNativeMethods.IOleInPlaceSite.GetWindowContext(IOleInPlaceFrame& ppFrame, IOleInPlaceUIWindow& ppDoc, COMRECT lprcPosRect, COMRECT lprcClipRect, tagOIFI lpFrameInfo)
   bei PDFXCviewAxLib.IPDFXCview2.SetDevInfo(String Key, String Code)
What is the right way to replace a "dead" viewer?

Best regards,
cew
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Problem creating new PDFControl

Post by Vasyl-Tracker Dev Team »

Hi cew.

I guess the using CreateControl() - is wrong way in case with ActiveX Controls that have own and required UI.
In our SDK-examples (C#), when we looking to Form1.Designer.cs - we can see next:

1. instatiating ActiveX object-wrapper:
this.axCoPDFXCview1 = new AxPDFXCviewAxLib.AxCoPDFXCview();

2. start initialization of control:
((System.ComponentModel.ISupportInitialize)(this.axCoPDFXCview1)).BeginInit();

3. intializing control attributes incliding position on the parent-form:
this.axCoPDFXCview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.axCoPDFXCview1.Enabled = true;
this.axCoPDFXCview1.Location = new System.Drawing.Point(409, 3);
this.axCoPDFXCview1.Name = "axCoPDFXCview1";
this.axCoPDFXCview1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axCoPDFXCview1.OcxState")));
this.axCoPDFXCview1.Size = new System.Drawing.Size(533, 737);
this.axCoPDFXCview1.TabIndex = 3;
this.axCoPDFXCview1.OnEvent += new AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEventHandler(this.axCoPDFXCview1_OnEvent);

3. adding to controls list:
this.Controls.Add(this.axCoPDFXCview1);

4. finalizing of ActiveX control creation:
((System.ComponentModel.ISupportInitialize)(this.axCoPDFXCview1)).EndInit();
- after that control will be ready to use.

HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Problem creating new PDFControl

Post by cew »

Great support, thank you!

Best regards,
cew
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Problem creating new PDFControl

Post by Tracker Supp-Stefan »

:D