title: C# call to WebService Server was unable to process request. ---> Object reference not set to an instance of an object
body: <p>I am trying to call a WebService via C# and am hitting a road block.  I cannot figure out why I am not able to make this call, I am calling other services using this same method, but this one passes an array and I think that is the issue...  I have tried many different ways of initalizing my array, and I think it is working right, but the error being thrown does not tell me which object is causing the issue...</p>
  
  <pre><code>public void addActionCall(SurveyUser tUser)
  {
      //Create Client Object
      RCServicesSoapClient sClient = new RCServicesSoapClient();
  
      //Create Action Array
      ActionItem[] tAction = new ActionItem[2];
  
      //Initialize first item in the array 
      tAction[0] = new ActionItem();
  
      //Assign values to first item
      tAction[0].ActionType = "permission to contact via email";
      tAction[0].ActionDefinedValue = "no";
  
      //Initialize second item
      tAction[1] = new ActionItem();
  
      //Assign values to second item
      tAction[1].ActionType = "age (if given):";
      tAction[1].ActionOpenValue = "33";
  
      //create AddAction Response
      AddActionResponseBody addActionResponse = new AddActionResponseBody();
  
      //Call AddAction WebService
      addActionResponse.AddActionResult = sClient.AddAction(tUser.Guid, "testinfo", "testinfo", tAction); //This is where it breaks
  
      Console.WriteLine("Status Code: " + addActionResponse.AddActionResult.statusCode);
      Console.WriteLine("Status Description: " + addActionResponse.AddActionResult.statusDesc);
      Console.WriteLine("AddAction Test Complete - Press Enter to Continue");
      Console.ReadLine();
  }
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Exception:</p>
  
  <pre><code>System.ServiceModel.FaultException was unhandled
    HResult=-2146233087
    Message=Server was unable to process request. ---&gt; Object reference not set to an instance of an object.
    Source=mscorlib
    StackTrace:
      Server stack trace: 
         at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc&amp; rpc)
         at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
         at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
         at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
      Exception rethrown at [0]: 
         at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
         at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
         at WebServicesTesting.RCWS.RCServicesSoap.AddAction(AddActionRequest request)
         at WebServicesTesting.RCWS.RCServicesSoapClient.WebServicesTesting.RCWS.RCServicesSoap.AddAction(AddActionRequest request) in C:\Users\chris.lovell\Documents\Visual Studio 2010\Projects\WebServicesTesting\WebServicesTesting\Service References\RCWS\Reference.cs:line 4686
         at WebServicesTesting.RCWS.RCServicesSoapClient.AddAction(String GUID, String ClientCode, String Domain, ActionItem[] Action) in C:\Users\chris.lovell\Documents\Visual Studio 2010\Projects\WebServicesTesting\WebServicesTesting\Service References\RCWS\Reference.cs:line 4696
         at WebServicesTesting.TestHarness.addActionCall(SurveyUser tUser) in C:\Users\chris.lovell\Documents\Visual Studio 2010\Projects\WebServicesTesting\WebServicesTesting\Program.cs:line 291
         at WebServicesTesting.WebServicesTest.Main(String[] args) in C:\Users\chris.lovell\Documents\Visual Studio 2010\Projects\WebServicesTesting\WebServicesTesting\Program.cs:line 73
         at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
         at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
         at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
         at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
         at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.ThreadHelper.ThreadStart()
  </code></pre>
  
  <p>AddAction Method:</p>
  
  <pre><code>public WebServicesTesting.RCWS.ActionItem AddAction(string GUID, string ClientCode, string Domain, WebServicesTesting.RCWS.ActionItem[] Action)
  {
      WebServicesTesting.RCWS.AddActionRequest inValue = new WebServicesTesting.RCWS.AddActionRequest();
      inValue.Body = new WebServicesTesting.RCWS.AddActionRequestBody();
      inValue.Body.GUID = GUID;
      inValue.Body.ClientCode = ClientCode;
      inValue.Body.Domain = Domain;
      inValue.Body.Action = Action;
      WebServicesTesting.RCWS.AddActionResponse retVal = ((WebServicesTesting.RCWS.RCServicesSoap)(this)).AddAction(inValue);
      return retVal.Body.AddActionResult;
  }
  </code></pre>