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

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?
 
C

Chris, Master of All Things Insignificant

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top