Monday 30 January 2012

Object reference not set to an instance of an object(call webservice)


Error:

Server Error in '/' Application.

Server was unable to process request. ---> Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Object reference not set to an instance of an object.

Source Error:


Line 891:        Public Function AddComment(ByVal content As String As String
Line 892:            Dim results() As Object = 
Me.Invoke("AddComment", New Object() {content)
Line 893:            Return CType(results(0),String)
Line 894:        End Function

Source File: D:\Develope\SoHoa\Sohoa2012\Test\Web References\commentservice\Reference.vb    Line: 892

Stack Trace:



[SoapException: Server was unable to process request. 
---> Object reference not set to an instance of an object.]
   System.Web.Services.Protocols.SoapHttpClientProtocol.
ReadResponse(SoapClientMessage message, 
WebResponse response, Stream responseStream, Boolean asyncCall) +431702
   System.Web.Services.Protocols.SoapHttpClientProtocol.
Invoke(String methodName, Object[] parameters) +204
   Test.commentservice.Service.AddComment(String content
   ASP.default_aspx.Page_Load(Object sender, EventArgs e) +92
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
 Boolean includeStagesAfterAsyncPoint) +627



Version Information: Microsoft .NET Framework Version:2.0.50727.5420; ASP.NET Version:2.0.50727.5420              



Resolve:

The error should occur at server side and I believe above code is taken from client side proxy class.
Try putting a debugger on the server side and see what is going on. This kind of error typically comes from code that assumes that an object exists
and users it when a null value is present. With the debugger you can figure out what line of code is failing, and then from that figure out what object reference is null. At the very least you will then know where you should be checking object references for null values.

No comments:

Post a Comment