I'm coverting Hussein Nasser VB code to C# but I'm having problems.
it's from his session:
The Vb code works but my converted C# crashes
here is my onclick code from form1 : Form
ERROR ->
System.NullReferenceException: Object reference not set to an instance of
OCCURS during the Assignment of pMap.
private void button1_Click(object sender, EventArgs e)
{
IMxDocument pMxDoc = (IMxDocument)_application.Document;
IMap pMap = pMxDoc.FocusMap;
}
vb code :
Private _application As IApplication
Public Property ArcMapApplication() As IApplication
Get
Return _application
End Get
Set(ByVal value As IApplication)
_application = value
End Set
End Property
c# code:
private IApplication _application;
public IApplication ArcMapApplication
{
get { return _application; }
set { _application = value; }
}
Solved! Go to Solution.
Hussein Nasser himself solved it for me ![]()
Hussein, thanks for the Great Video series on Extending ArcObjects.
Double Thanks for providing me help.
Hussein Nasser himself solved it for me ![]()
Hussein, thanks for the Great Video series on Extending ArcObjects.
Double Thanks for providing me help.
In what context are you running this code? - for example within an Add-In, old style COM extension, etc.
Has your _application object already been set or is it null?
EDIT - I got side-tracked and should have refreshed before posting to see if an answer had already been posted ![]()