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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy A38

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

    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\12 34.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\12 35.PDF"

    ....I get the following error:

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

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


    So what am I doing wrong?


    --
    Andy, MCDBA
  • Chris, Master of All Things Insignificant

    #2
    Re: Object reference not set to an instance of an object (PDF Reader O

    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




    "Andy A38" <AndyA38@discus sions.microsoft .com> wrote in message
    news:FFCF650A-C554-4763-B919-230FA91D47ED@mi crosoft.com...[color=blue]
    >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\12 34.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\12 35.PDF"
    >
    > ...I get the following error:
    >
    > An unhandled exception of type 'System.NullRef erenceException ' occurred in
    > mscorlib.dll
    >
    > Additional information: Object reference not set to an instance of an
    > object.
    >
    >
    > So what am I doing wrong?
    >
    >
    > --
    > Andy, MCDBA[/color]


    Comment

    Working...