NullReferenceException was unhandled
Hi could somebody please help me with this as i have been trying to fix it for hours!!!
I keep receving the "NullReferenceException was unhandled " message in the line in bold
public static Conditions GetCurrentConditions(string location)
{
Conditions c;
c = null;
c = new Conditions();
c.GetCurrentConditions();
XmlDocument xmlConditions = new XmlDocument();
xmlConditions.Load(string.Format("http://www.google.com/ig/api?weather={0}", location));
if (xmlConditions.SelectSingleNode("xml_api_reply/weather/problem_cause") != null)
{
c = null;
}
else
{
Conditions cond = new Conditions();
cond.Town = xmlConditions.SelectSingleNode("/xml_api_reply/weather/forecast_information/city").Attributes["data"].InnerText;
cond.Condition = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/condition").Attributes["data"].InnerText;
cond.TempC = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/temp_c").Attributes["data"].InnerText;
cond.TempF = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/temp_f").Attributes["data"].InnerText;
cond.Humidity = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/humidity").Attributes["data"].InnerText;
cond.Wind = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/wind_condition").Attributes["data"].InnerText;
}
return c;
}
Answers (1)
0
Hi Bikesh Srivastava, I didn't exactly understand what you want to convey. I am doing my service method implementation in base class only.
public class Monitor : IMonitor
{
public Task AddMonitor(Monitor mo)
{
// Implementation goes here
}
public Task RemoveMonitor(Monitor mo)
{
// Implementation goes here
}
}
But anyway my code id now working. Once i decorated my IMonitorCallback with (IsOneWay = true)] its started working perfectly.
interface IMonitorCallback
{
[OperationContract(IsOneWay = true)]
void OnAdded(Monitor data);
[OperationContract(IsOneWay = true)]
void OnRemoved(Monitor data);
}
0
I think you need to understand of WCF in deep.
because if you are creating interface and implement then you have to declare all method in base class.
0
http://stackoverflow.com/questions/22466523/405-method-not-allowed-wcf-web-service-after-second-request