I'm using google earth in my C# application and it almost works fine, but occasionally I get the message
Google earth has encountered a problem ...
and supposedly it crashes (Although it's still running underneath).
what seems to be the problem here?
I thought maybe the problem is calling the google earth methods too frequently so I fixed it but still no good news...
One of the functions it crashes in is :
puvlic void clearKMLFile()
{
try
{
XmlDocument mainXml = new XmlDocument();
mainXml.Load(strKMLPath);
string strRoot = "kml/Document/Folder";
XmlNode ndPlaceRoot = mainXml.SelectSingleNode(strRoot);
for (int j=0;j<5;j++)
{
for(int i=0;i<ndPlaceRoot.ChildNodes.Count;i++)
{
if(ndPlaceRoot.ChildNodes[i].Name == "Placemark")
{
if(ndPlaceRoot.ChildNodes[i].Attributes.Count != 0)
{
ndPlaceRoot.RemoceChild(ndPlaceRoot.ChildNodes[i]);
mainXml.Save(strKMLPath);
}
}
}
}
}
try
{
ge.OpenKmlFile(strKMLPath,1); //this is the only Google earth API method used here
}
catch (Exception ex)
{
MessageBox.Show("An error occurred in clearring process!");
}
}
The error message itself :
Finally found out what the problem was ...
For future refrence:
I was calling the ge.OpenKmlFile()
method two times in a row very fast in my code, so google earth was crashing. Fixed the calls and the problem went away for now.