We help IT Professionals succeed at work.
Get Started

Object reference not set to an instance of an object.

mploschiavo asked
Last Modified: 2008-01-09
i am trying to use pdf maker class .net  found at

just for testing the class, i am loading a web page with a hard coded input and output file name.  the files already exist in the temp directory.  i will be integrating this into an asp .net and c# app.    the whole purpose of this test is to evaluate the output file. (i used verypdf but this package maybe a better approach, if i can get it work.)  what do i need to change to get this package to work?

here's my error
Server Error in '/test1' Application.

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 69:                   //System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
Line 70:                   //System.Cursor.Current = Cursors.WaitCursor;
Line 71:                   oPDFmaker.CloseAcrobat(); // ensure Acrobat is closed
Line 72:                
Line 73:            

Source File: c:\inetpub\wwwroot\test1\webform2.aspx.cs    Line: 71

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   test1.WebForm2.InitializeComponent() in c:\inetpub\wwwroot\test1\webform2.aspx.cs:71
   test1.WebForm2.OnInit(EventArgs e) in c:\inetpub\wwwroot\test1\webform2.aspx.cs:44
   System.Web.UI.Control.InitRecursive(Control namingContainer) +241
   System.Web.UI.Page.ProcessRequestMain() +197


Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

here is my
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using SkySof;
using System.IO;
//using SkySof.CreatePDF;

namespace test1
      /// <summary>
      /// Summary description for WebForm2.
      /// </summary>

      public class WebForm2 : System.Web.UI.Page
            public /* TRANSINFO: WithEvents */ CreatePDF oPDFmaker;
            public string AppName;
            public string AppPath;
            private void Page_Load(object sender, System.EventArgs e)
                  CreatePDF oPDFMaker = new CreatePDF();
                  oPDFMaker.TempFilePath = @"c:\temp";
                  //AppName = "PDF Maker Class .NET Demo";
                  //this.Text = AppName + " - Acrobat Version: " + oPDFmaker.AcrobatVersion() + ", Print Driver: " + oPDFmaker.PrinterName() + ", Temporary File Path: " + oPDFmaker.TempFilePath;
                  // AppPath = Application.StartupPath
                  //AppPath = @"C:\Program Files\SkySof Software Inc\PDF Maker Class .NET";
                  string AppPath = @"c:\temp";

                  string strPDF;
                  string strDOC;
                  //string strPagesToPrint;
                  //System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                  //System.Cursor.Current = Cursors.WaitCursor;
                  //oPDFmaker.CloseAcrobat(); // ensure Acrobat is closed
                  strPDF = AppPath + @"\test.pdf";
                  strDOC = AppPath + @"\test.doc";
                  //strPagesToPrint = "1, 3, 6-8, 10";
                  //oPDFmaker.CreatePDFfromWord( strPDF, strDOC, "", "", strPagesToPrint, chkSecurity.Checked );
                  oPDFmaker.CreatePDFfromWord( strPDF, strDOC);
                  // Release any open objects from memory
                  // open PDF file
                  oPDFmaker.OpenPDF( strPDF, 6 ); ;


            #region Web Form Designer generated code
            override protected void OnInit(EventArgs e)
                  // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
                  this.Load += new System.EventHandler(this.Page_Load);


here is my
<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="test1.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
            <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
            <meta name="CODE_LANGUAGE" Content="C#">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
      <body MS_POSITIONING="GridLayout">
            <form id="Form1" method="post" runat="server">
                  its works.
                  <table cols="1">

Watch Question
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE