How to manage events with AxCDIntfEx (Addhandler)?

The PDF Creator enables you to create secure PDF documents and to view, print and process existing PDF documents.
If you have any questions about the installation and usage of the PDF Creator please post them here.
Post Reply
Grenville
Posts: 4
Joined: Mon Aug 13 2007

How to manage events with AxCDIntfEx (Addhandler)?

Post by Grenville »

Case with .Net 2005:

(Add a reference to a AxInterop.CDIntfEx,copy&paste the code in a new project:)
Imports AxCDIntfEx

Public Class Form1

Friend WithEvents cdi As New AxCDIntfEx.AxCDIntfEx

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cdi.DriverInit("printerrific.net")
AddHandler cdi.StartPage, AddressOf StartPage_Function
cdi.SetDefaultPrinter()
cdi.CaptureEvents(1)
End Sub

Private Sub StartPage_Function(ByVal sender As Object, ByVal e As AxCDIntfEx._DCDIntfEvents_StartPageEvent)
MsgBox("StartPage_Function")
End Sub
End Class

***************************
Throws:
System.IO.FileNotFoundException was unhandled
Message="Could not load file or assembly 'Interop.CDIntfEx, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies."

1. Does exists a dependence between AxInterop.CDIntfEx and Interop.CDIntfEx?

Include reference Interop.CDIntfEx.dll

Throws:
System.Windows.Forms.AxHost.InvalidActiveXStateException was unhandled Message="Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown." Source="AxInterop.CDIntfEx"

Im planning to make it work at the end as a service.

Any help will be appreciated.
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

I suggest that you try this:

1- Add a reference to a AxInterop.CDIntfEx

2-
Imports CDIntfEx
Dim cdi As New CDIntfEx.CDIntfEx

Hope this helps?
Grenville
Posts: 4
Joined: Mon Aug 13 2007

Thanks

Post by Grenville »

Hi, I tried it succesfully.

It works fine with windows applications, but not with windows services. Looks like the cdintfex needs a form -a container- to receive the events and work properly. Not sure, but Im working -by now- as a windows application.

Thanks, Jose!
Post Reply