title: Passing a derived class to a web service method that takes an abstract type
body: <p>I have a bizarre problem that is doing my head in. </p>
  
  <p>I have the following classes defined in a single project:</p>
  
  <pre><code>public abstract class AbstractUnitModel {
  
        public void executeRemoteModel(){}
  
  }
  
  //this class also implements a seperate interface, but I dont think that is the issue
  public class BlastFurnaceUnitModel : AbstractUnitModel, IUnitModel {}
  </code></pre>
  
  <p>Now if I try something like this, it works as expected:</p>
  
  <pre><code>class Class1
  {
  
      public void method1() {
  
          BlastFurnaceUnitModel b = new BlastFurnaceUnitModel();
          method2(b);
      }
  
      public void method2(AbstractUnitModel a) {}
  
   }
  </code></pre>
  
  <p>Now I have another project that exposes a web method. This method takes an AbstractUnitModel and executes it remotely, then sends the results back to the client. So on the server I have this:</p>
  
  <pre><code> [WebMethod]
   public AbstractUnitModel remotelyExecuteUnitModel(UnitModelWrapperInterface.AbstractUnitModel unitModel)
          {
  
             unitModel.executeRemoteModel();
             return unitModel;
  
           }
  </code></pre>
  
  <p>And on the client I have this: </p>
  
  <pre><code>   public void remoteExecution() {
  
                  var unitModelWebService = new UnitModelRemoteServer.RemoteModelExecutionWebService();
                  unitModelWebService.remotelyExecuteUnitModelCompleted += new UnitModelRemoteServer.remotelyExecuteUnitModelCompletedEventHandler(remoteExecutionCompleted);
                  unitModelWebService.remotelyExecuteUnitModelAsync(this.remoteBF);
              }
  </code></pre>
  
  <p>But my project will not compile, and I get these errors:
  <em>Error  109 The best overloaded method match for 'CalibrationClient.UnitModelRemoteServer.RemoteModelExecutionWebService.remotelyExecuteUnitModelAsync(CalibrationClient.UnitModelRemoteServer.AbstractUnitModel)' has some invalid arguments</em>  </p>
  
  <p><em>Error  110 Argument '1': cannot convert from 'UnitModelWrapperInterface.BlastFurnaceUnitModel' to 'CalibrationClient.UnitModelRemoteServer.AbstractUnitModel'</em> </p>
  
  <p>I can not figure out why this is happening. I have references in the server project to the namespace where AbstractUnitModel is defined. The only thing that looked a little funny to me is that it is using AbstractUnitModel from the 'CalibrationClient' namespace rather than the UnitModelWrapperInterface. It seems when VS generates the proxy for a webservice on the client it creates a partial abstract implementation of AbstractUnitModel. Is this the source of my problem? If so, how might I go about fixing it? </p>
  
  <p>edit for solution: As pointed out, the client needs to know about all classes that could be sent across the wire. I ended up solving this by removing the generated proxy classes and referencing the common library. Not ideal but good enough in this situation.  </p>