Late-binding PDF-XChange Viewer-Event OnEvent impossible  SOLVED

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

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

KarlTH
User
Posts: 57
Joined: Mon Aug 01, 2005 2:33 pm

Late-binding PDF-XChange Viewer-Event OnEvent impossible

Post by KarlTH »

Hello Tracker-Support,

I am using your PDF-XChange Viewer in my VB .NET application and using always the latest version of PDF-XChange Viewer ActiveX SDK on my development PC. Our users have earlier versions of PDF-XChange Viewer ActiveX SDK installed on their computers and so I have the problem if I deploy my application to them it crashes because the COM-Wrapper is not the same version as mine. :evil:
To fix this problem I decided to late-bind the PDF-XChange Viewer control with Reflection-class and it works but I receive no event with GetEvent if I try to listen to OnEvent.

Here is how I tried it in a windows form application:

Code: Select all

        '######## Listen to PDF-XChange Viewer-event OnEvent ###############################
        Dim tPDFXCView As Type = Type.GetTypeFromProgID("PDFXCviewAx.CoPDFXCview")
        Dim oPDFXCView As Object = Activator.CreateInstance(tPDFXCView)
        oPDFXCView = Activator.CreateInstance(tPDFXCView)

        Debug.WriteLine(tPDFXCView.GetEvents())
        
        Dim evPDFXCOnEvent As EventInfo = tPDFXCView.GetEvent("OnEvent")
        Debug.WriteLine(evPDFXCOnEvent)
        'Returns Nothing
If I do the same with the Word COM-Object it returns an event:

Code: Select all

        '######## Listen to Word event DocumentChange ###############################
        Dim tPDFXCView As Type = Type.GetTypeFromProgID("Word.Application")
        Dim oPDFXCView As Object = Activator.CreateInstance(tPDFXCView)
        oPDFXCView = Activator.CreateInstance(tPDFXCView)

        Debug.WriteLine(tPDFXCView.GetEvents())
        
        Dim evPDFXCOnEvent As EventInfo = tPDFXCView.GetEvent("DocumentChange")
        Debug.WriteLine(evPDFXCOnEvent)
        'Returns Microsoft.Office.Interop.Word.ApplicationEvents4_DocumentChangeEventHandler DocumentChange
How can I get the OnEvent of PDF-XChange Viewer control with GetEvent?


Thanks a lot!

Karl
KarlTH
User
Posts: 57
Joined: Mon Aug 01, 2005 2:33 pm

Re: Late-binding PDF-XChange Viewer-Event OnEvent impossible

Post by KarlTH »

Hello Tracker-Support,

good news I have solved the problem by myself!
You have to create an event sink in your application to communicate with the PDF-XChange Viewer Active X-COM server and then you will receive the OnEvent in VB .NET.

Here is a good C# example which helped me very much:
http://www.codeproject.com/Articles/102 ... OM-servers

Now I can completely late-bind the PDF-XChange Viewer Active X control with Reflection-class! Cool! 8)


Best regards,

Karl
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Late-binding PDF-XChange Viewer-Event OnEvent impossible

Post by Stefan - PDF-XChange »

Hi Karl,

Glad to hear you've solved it yourself, and thanks for sharing the solution!
Hopefully it will be useful to other devs as well!

Cheers,
Stefan
KarlTH
User
Posts: 57
Joined: Mon Aug 01, 2005 2:33 pm

Re: Late-binding PDF-XChange Viewer-Event OnEvent impossible

Post by KarlTH »

Hello Stefan,

you are welcome!
Was not easy and I hope it will help other .NET developers too!


Best regards,

Karl
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Late-binding PDF-XChange Viewer-Event OnEvent impossible

Post by Stefan - PDF-XChange »

:)