asri.chejarla

Object reference not set to an instance of an object.

Discussion created by asri.chejarla on Feb 8, 2011
Latest reply on Feb 10, 2011 by asri.chejarla
Hi All,

I am using C# for ArcObjects desktop. Kindly clarify me on the below to declarations

1.   IApplicatin app = IMxDocument.doc as IApplication;
      ----
-------
throws an exception (NUllReferenceException) when i use
app.OpenDocument(filename)------ where filename is a string in the openFileDialog1

2.    IApplication app = (IMxDocument.doc as IDocument).Parent
---
---
This does not throw an exception. My doubt is why does the first option throw an error while second option does not even though both IApplication & IDocument.Parent both refer to Application.

Thanks a lot in advance...!

Outcomes