title: How to use a custom type object at the client
body: <p>I'm new to C# and to WCF, coming from a Java background.</p>
  
  <p>I'm have a solution with a WCF service hosted on IIS that has an Employee class, and a method...</p>
  
  <pre><code>public Employee getEmployee(int loginId)
  </code></pre>
  
  <p>This method takes the loginId, queries the database and creates an Employee object with the results, and then returns the Employee object.  Simple enough.</p>
  
  <p>So I have a client, and thus far all it does is call a simple "Hello World" web method to prove to me that it's configured right to talk to the service.  Now I want a login button to take the entered loginId, call getEmployee, and create a local Employee object with the returned value.</p>
  
  <p>So, I'm confused on the point of how I should define the Employee class at the client?  There's not alot of info out there on how to do something so simple; like with AXIS2 and NetBeans for Java this would be utterly simple with lots of tutorials to show how, but for WCF it seems every tutorial just assumes certain knowledge that I don't have.</p>
  
  <p>So the post below says that this can be done by having my Employee class defined in a separate assembly, and reference the .dll from both the WCF Service project and the client project (both are in separate solutions by the way).</p>
  
  <p><a href="https://stackoverflow.com/questions/7718875/wcf-passing-a-custom-object-to-client-and-running-its-methods">WCF passing a custom object to client and running it&#39;s methods</a></p>
  
  <p>It says "you can create a contracts assembly (an assembly that contains your thin domain models (e.g. Person etc) which you can add your own logic to.", but doesn't explain how to do this or give any reference to where I can find more information or instructions.</p>
  
  <p>My Employee class is already defined directly in the WCF Service project anyways.  If someone can give any info on how to move it to a "contracts assembly" (I'm C# noob and haven't even ever created a DLL before; just Windows Forms projects), that would be much appreciated.</p>
  
  <p>Also, I see in another answer on the same post the following...</p>
  
  <p>"1.If you can't change sources of the dll and want to call public method of the dll, it is better to use reflection. So, you receive object from WCF, sets Person properties with values returned, call method."</p>
  
  <p>I understand the concept above; I would define a separate Employee class at the client, and then somehow use reflection to get the values from the object that the web method returns, and assign them to a new Employee object, right?.  Only, I don't have any idea how to use reflection to get values for that.</p>
  
  <p>What's best practice?  Should I define an IEmployee interface like this other post suggests, and then put it in a DLL with the regular Employee class, and reference that from both server and client, and return IEmployee instead of Employee from the web method?  If that's the best thing to do, is there anything special that has to be done, or can I literally just do something like this so long as such a DLL is references on both sides?</p>
  
  <pre><code>int loginId = Int32.Parse(this.loginInputTxt.Text);
  LaborService.LaborServiceClient proxy = new LaborService.LaborServiceClient();
  Employee emp = (Employee)proxy.getEmployee(loginId);
  </code></pre>