Object reference not set to an instance of an object (PDF Reader O

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have placed an ActiveX PDF control (the Adobe Reader OCX) on a .Net Windows
form and manually set the "src" property to "c:\myfolder\1234.PDF". The
control displays this file when the application is run. So far so good.

However, when I add a button to change the src file (to be displayed) with a
single line of code in the button click event as shown below:

AxPdf1.src = "c:\myfolder\1235.PDF"

....I get the following error:

An unhandled exception of type 'System.NullReferenceException' occurred in
mscorlib.dll

Additional information: Object reference not set to an instance of an object.


So what am I doing wrong?
 
If you look in debug you will probably notice that AxPdf1 is set to a value
of nothing. You need to instantiate it with a line like
AxPdf1 = New ........ Normally this is taken care of by placing the OCX on
the form. Step through the code to see if it ever has a value and if it
loses it somewhere.

Hope this helps some.
Chris
 
Back
Top