We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Word to PDF conversion throws NullReferenceException using C#

Conversion of word files to PDF failed with Aspose.word (ver.10.6). Following are 3 null reference exceptions and code snippet. Can you please provide fix asap?
Code:
        public static void ConvertWordToPdf(string sourceFilePath, string destinationFilePath)
        {                     
            Aspose.Words.Document doc = new Aspose.Words.Document(sourceFilePath);
                                    doc.Save(destinationFilePath,Aspose.Words.SaveFormat.Pdf);           
    }</span></pre>exception:</pre><pre style="color: rgb(0, 0, 0); font-weight: normal; word-wrap: break-word; white-space: pre-wrap; ">1/20/2012 10:30:05 PM

Message: HandlingInstanceID: e99f21df-1045-4afb-864f-4d9b178d6b3d

An exception of type
‘System.NullReferenceException’ occurred and was caught.
2012-01-20 17:30:05Z

System.NullReferenceException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Object reference not set to an instance of an object.

Aspose.Words in file: C:\WINDOWS\TEMP\IntraLinks\f680a23d-c50f-4e62- bd91-d0f64bc4d845.doc System.Collections.ListDictionaryInternal Int32 䣂(㚮.䢈) at 㚮.䢶.䣂(䢈 Ḩ) at 㚮.䣈.䣋(䟘 Ẇ) at 㚮.䣈.䣂(䟘 Ẇ, Boolean 䢾) at 㚮.䟘 .get_䓃() at 㚮.䢶.䣁(䢈 Ḩ, Boolean 䢾) at 㚮.䢶.䜐(䢈 Ḩ) at Ἕ.䪉.get_䪋() at 㘤.䪐.䤖(䪉 Ḩ) at Ἕ.䪉.䒺(䤅 Ւ) at Ἕ.䪂.䒺( 䤅 Ւ) at Ἕ.䪁.䒺(䤅 Ւ) at Ἕ.䫔.䫖(⭎ ၅, 䤅 Ւ) at Ἕ.䫔.䒺(䤅 Ւ) at Ἕ.䪰.䒺(䤅 Ւ) at Ἕ.䤡.䒺(䤅 Ւ) at 㘤.䪐.㓳(䤡 䪝, Ө 䩆)\r \n at Aspose.Words.Document.SaveToPdf(Int32 pageIndex, Int32 pageCount, Stream stream, PdfOptions pdfOptions) at Aspose.Words.Document.SaveToPdf (Int32 pageIndex, Int32 pageCount, String fileName, PdfOptions pdfOptions) at Aspose.Words.Document.SaveToPdf(String fileName) at Intralinks.Common.Utilities.AsposeConverter.ConvertWordToPdf(String sourceFilePath, String destinationFilePath) in c:\ilbuilds\pdfconv\build_trunk \CommonUtilities\AsposeConverter.cs:line 39 at Intralinks.Common.Utilities.CommonUtilities.ConvertOfficeDocsToPDF(String sourceFile, String destinationFolder, Boolean useOriginalFileName) in c:\ilbuilds\pdfconv\build_trunk\CommonUtilities\CommonUtilities.cs:line 1357 Category: Logging Exception Priority: 1 EventId: 100 Severity: Error\r \nTitle:Enterprise Library Exception Handling Machine: WDPDPF01 Application Domain: ILPDFConversionService.exe Process Id: 3112 Process Name: C: \PDFConvService\WOODDALE.pdfconv\instance5\Release\ILPDFConversionService.exe Win32 Thread Id: 7304 Thread Name: Extended Properties: Product Version - 3.0.24944.0


Timestamp: 1/20/2012 10:19:41 AM
Message: HandlingInstanceID: cc2eafae-7c54-42c8-a5f9-5ca1940fe820

  An exception of type 'System.NullReferenceException' occurred and was caught.
  2012-01-20 05:19:41Z
  System.NullReferenceException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  Object reference not set to an instance of an object.
  Aspose.Words in file: C:\WINDOWS\TEMP\IntraLinks\2889ddf6-c7f1-4ef2-bfcc-50d925c1a6c2.doc
  
  System.Collections.ListDictionaryInternal
  Void 䢱(㚮.䢈)
     at 㚮.䢥.䢱(䢈 䢲)
   at 㚮.䢥.䢰(䢈 Ḩ)
   at 㚮.䢥.䢯(䟘 Ẇ)
   at 㚮.䢥.䢩(䟘 Ẇ, Boolean 䢪)
   at 㚮.䢥.㗑(䟘 Ẇ, Int32 䢔)
   at 㚮.䟘.㗑(Int32 䓬)
   at 㚮.䬂.䬘(䟘 Ẇ, Int32 䢔)
   at 㚮.䬂.䬍(⭎ ၅, Int32 䢔)
   at 㚮.䬂.㗑(Int32 䢔)
   at 㚮.䫯.䫷()
   at 㚮.䫯.㗑(Int32 䢔)
   at 㚮.䞄.㗑(Int32 䓬)
   at 㚮.䫗.䫙(䞄 㥻)
   at 㚮.䫗.䫘(䔗 ⍰)
   at 㚮.䭓.㗑(䔗 䓽)
   at 㚮.䔗.㗑(Boolean 䔊)
   at 㚮.䓋.㗑(Boolean 䔊)
   at 㚮.䖯.㗑(Boolean 䔊)
   at Ἕ.ӧ.䒵(Document ๗, Ө 㒱)
   at Aspose.Words.Document.UpdatePageLayout()
   at Aspose.Words.Document.get_ӧ()
   at Aspose.Words.Document.SaveToPdf(String fileName)
   at Intralinks.Common.Utilities.AsposeConverter.ConvertWordToPdf(String sourceFilePath, String destinationFilePath) in c:\ilbuilds\pdfconv\build_trunk\CommonUtilities\AsposeConverter.cs:line 39
   at Intralinks.Common.Utilities.CommonUtilities.ConvertOfficeDocsToPDF(String sourceFile, String destinationFolder, Boolean useOriginalFileName) in c:\ilbuilds\pdfconv\build_trunk\CommonUtilities\CommonUtilities.cs:line 1357
  
    
    
    
    
    
    
  

Category: Logging Exception
Priority: 1
EventId: 100
Severity: Error
Title:Enterprise Library Exception Handling

Timestamp: 1/20/2012 4:39:08 AM
Message: HandlingInstanceID: e09e8ba9-3e9d-4485-b3ea-63d2bacb0293

  An exception of type 'System.NullReferenceException' occurred and was caught.
  2012-01-19 23:39:08Z
  System.NullReferenceException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  Object reference not set to an instance of an object.
  Aspose.Words in file: C:\WINDOWS\TEMP\IntraLinks\e6602377-3822-46dc-978c-d37f863d5e37.doc
  
  System.Collections.ListDictionaryInternal
  Void .ctor(㚮.䢈, 㚮.䢈)
     at Ἕ.䪉..ctor(䢈 shared, 䢈 sink)
   at 㘤.䪐.䪫(䪉 Ḩ)
   at 㘤.䪐.䤗(䪉 Ḩ)
   at Ἕ.䪉.䒺(䤅 Ւ)
   at Ἕ.䪂.䒺(䤅 Ւ)
   at Ἕ.䪁.䒺(䤅 Ւ)
   at Ἕ.䫔.䫖(⭎ ၅, 䤅 Ւ)
   at Ἕ.䫔.䒺(䤅 Ւ)
   at Ἕ.䪰.䒺(䤅 Ւ)
   at Ἕ.䤡.䒺(䤅 Ւ)
   at 㘤.䪐.㓳(䤡 䪝, Ө 䩆)
   at Aspose.Words.Document.SaveToPdf(Int32 pageIndex, Int32 pageCount, Stream stream, PdfOptions pdfOptions)
   at Aspose.Words.Document.SaveToPdf(Int32 pageIndex, Int32 pageCount, String fileName, PdfOptions pdfOptions)
   at Aspose.Words.Document.SaveToPdf(String fileName)
   at Intralinks.Common.Utilities.AsposeConverter.ConvertWordToPdf(String sourceFilePath, String destinationFilePath) in c:\ilbuilds\pdfconv\build_trunk\CommonUtilities\AsposeConverter.cs:line 39
   at Intralinks.Common.Utilities.CommonUtilities.ConvertOfficeDocsToPDF(String sourceFile, String destinationFolder, Boolean useOriginalFileName) in c:\ilbuilds\pdfconv\build_trunk\CommonUtilities\CommonUtilities.cs:line 1357
  
    
    
    
    
    
    
  

Category: Logging Exception
Priority: 1
EventId: 100
Severity: Error
Title:Enterprise Library Exception Handling
Machine: WDPDPF01
Application Domain: ILPDFConversionService.exe
Process Id: 6240
Process Name: C:\PDFConvService\WOODDALE.pdfconv\instance1\Release\ILPDFConversionService.exe
Win32 Thread Id: 3776
Thread Name: 
Extended Properties: Product Version - 3.0.24944.0

Hi Viral,

Thanks for your query. Please use the latest version of Aspose.Words for .NET 11.0.0. If you still face problem then please share your document for investigation purposes.

Well as you know few days back only we upgraded all dlls but still we got lot of nullReferenceExceptions. Can you please check if this issue fixed recently with latest dll?

Hi Viral,

It would be great, If you share your document for investigation purposes.