Value cannot be null. Parameter name: Internal Error: The instance of the MessageContract cannot be null

Topics: Service Factory Modeling Edition Forum
Jan 19, 2010 at 5:51 PM

I am using the Web Service Software Factory for the first time.  I have gone through the hands-on lab with success and I am now trying to duplicate the behavior in my own problem domain.  I followed the hands-on lab through my own problem domain and upon refactoring my service I receive the following exception:

Value cannot be null.\r\nParameter name: Internal Error: The instance of the MessageContract cannot be null

This error is occurring on the client when the call is being made.  I believe there is something wrong with the request message but I don't know how to debug it or determine how to correct the problem.  In my code the request is not null because I create one just prior to making the call to the service.

Here is the detail of the exception:

 

System.ServiceModel.FaultException`1 was unhandled
  Message="Value cannot be null.\r\nParameter name: Internal Error: The instance of the MessageContract cannot be null in http://edu.wyoming.gov/ActionPlan/services/2010/01/ActionPlanMgmtServiceContract/GetWebActionPlanCount."
  Source="mscorlib"
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       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& msgData, Int32 type)
       at WDE.ActionPlan.Svc.WCF.Client.ActionPlanMgmtProxy.ActionPlanMgmtServiceContract.GetWebActionPlanCount(ActionPlanCountRequest1 request)
       at WDE.ActionPlan.Svc.WCF.Client.ActionPlanMgmtProxy.ActionPlanMgmtServiceContractClient.WDE.ActionPlan.Svc.WCF.Client.ActionPlanMgmtProxy.ActionPlanMgmtServiceContract.GetWebActionPlanCount(ActionPlanCountRequest1 request) in C:\WDE\Action Plan R1 Services\WDE.ActionPlan.Svc.WCF\Tests\WDE.ActionPlan.Svc.WCF.Client\Service References\ActionPlanMgmtProxy.cs:line 891
       at WDE.ActionPlan.Svc.WCF.Client.ActionPlanMgmtProxy.ActionPlanMgmtServiceContractClient.GetWebActionPlanCount(ActionPlanCountRequest ActionPlanCountRequest) in C:\WDE\Action Plan R1 Services\WDE.ActionPlan.Svc.WCF\Tests\WDE.ActionPlan.Svc.WCF.Client\Service References\ActionPlanMgmtProxy.cs:line 898
       at WDE.ActionPlan.Svc.WCF.Client.MainForm.button1_Click(Object sender, EventArgs e) in C:\WDE\Action Plan R1 Services\WDE.ActionPlan.Svc.WCF\Tests\WDE.ActionPlan.Svc.WCF.Client\MainForm.cs:line 69
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at WDE.ActionPlan.Svc.WCF.Client.Program.Main() in C:\WDE\Action Plan R1 Services\WDE.ActionPlan.Svc.WCF\Tests\WDE.ActionPlan.Svc.WCF.Client\Program.cs:line 16
       at System.AppDomain._nExecuteAssembly(Assembly 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.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

System.ServiceModel.FaultException`1 was unhandled

  Message="Value cannot be null.\r\nParameter name: Internal Error: The instance of the MessageContract cannot be null in http://edu.wyoming.gov/ActionPlan/services/2010/01/ActionPlanMgmtServiceContract/GetWebActionPlanCount."

  Source="mscorlib"

  StackTrace:

    Server stack trace: 

       at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)

       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)

       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)

       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& msgData, Int32 type)

       at WDE.ActionPlan.Svc.WCF.Client.ActionPlanMgmtProxy.ActionPlanMgmtServiceContract.GetWebActionPlanCount(ActionPlanCountRequest1 request)

       at WDE.ActionPlan.Svc.WCF.Client.ActionPlanMgmtProxy.ActionPlanMgmtServiceContractClient.WDE.ActionPlan.Svc.WCF.Client.ActionPlanMgmtProxy.ActionPlanMgmtServiceContract.GetWebActionPlanCount(ActionPlanCountRequest1 request) in C:\WDE\Action Plan R1 Services\WDE.ActionPlan.Svc.WCF\Tests\WDE.ActionPlan.Svc.WCF.Client\Service References\ActionPlanMgmtProxy.cs:line 891

       at WDE.ActionPlan.Svc.WCF.Client.ActionPlanMgmtProxy.ActionPlanMgmtServiceContractClient.GetWebActionPlanCount(ActionPlanCountRequest ActionPlanCountRequest) in C:\WDE\Action Plan R1 Services\WDE.ActionPlan.Svc.WCF\Tests\WDE.ActionPlan.Svc.WCF.Client\Service References\ActionPlanMgmtProxy.cs:line 898

       at WDE.ActionPlan.Svc.WCF.Client.MainForm.button1_Click(Object sender, EventArgs e) in C:\WDE\Action Plan R1 Services\WDE.ActionPlan.Svc.WCF\Tests\WDE.ActionPlan.Svc.WCF.Client\MainForm.cs:line 69

       at System.Windows.Forms.Control.OnClick(EventArgs e)

       at System.Windows.Forms.Button.OnClick(EventArgs e)

       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

       at System.Windows.Forms.Control.WndProc(Message& m)

       at System.Windows.Forms.ButtonBase.WndProc(Message& m)

       at System.Windows.Forms.Button.WndProc(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

       at System.Windows.Forms.Application.Run(Form mainForm)

       at WDE.ActionPlan.Svc.WCF.Client.Program.Main() in C:\WDE\Action Plan R1 Services\WDE.ActionPlan.Svc.WCF\Tests\WDE.ActionPlan.Svc.WCF.Client\Program.cs:line 16

       at System.AppDomain._nExecuteAssembly(Assembly 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.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading.ThreadHelper.ThreadStart()

  InnerException: 

 

Jan 20, 2010 at 5:14 PM

You should do 3 things

1. Locate the service implementation clases... In the project <WSSF Project>\Source\Service Interface\<WSSF Project>.ServiceImplementation\ there are several <Service>.cs files. Those files refer to each service you design in your model.

2. Deploy the abstract class (you will probably call and refer to your business project for each method).

3. Implement the partial class (creating all the override methods as well as they exists in the abstract class).

Jan 21, 2010 at 7:36 PM

You can also take a look at your proxy code.

Did you check this line at runtime for any null value of the request? C:\WDE\Action Plan R1 Services\WDE.ActionPlan.Svc.WCF\Tests\WDE.ActionPlan.Svc.WCF.Client\Service References\ActionPlanMgmtProxy.cs:line 891

If that's not the line that executes just after the call to the service operation, I would also take a look at that point and inspect if the request has everything set fine.