title: Passing DTO's from a seperate Project to UI Layer WCF RIA services
body: <p>I have a solution that I have designed with 5 layers. </p>
  
  <p>They are:</p>
  
  <ul>
  <li>UI/Presentation Layer</li>
  <li>Service Layer</li>
  <li>Business Logic Layer</li>
  <li>Data Access Layer</li>
  <li>DTO/Common Layer (IQUTECHDTO)</li>
  </ul>
  
  <p>I want to pass the DTO to the UI. Below is the service layer that exposes a method GetVendors which I want to return the VendorDTO. This object will populate a drop down box.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.ComponentModel.DataAnnotations;
  using System.Linq;
  using System.ServiceModel.DomainServices.Hosting;
  using System.ServiceModel.DomainServices.Server;
  using IQUTechDTO;
  using IQUTECHDAL;
  
  namespace BusinessApplication6.Web.Services
  {
  
      public class Foos
      {
  
          [Key]
  
          public int FooId { get; set; }
  
          public string Name { get; set; }
  
      }
  
      // TODO: Create methods containing your application logic.
      [EnableClientAccess()]
      public class BillService : DomainService
      {
  
          public IEnumerable&lt;Foos&gt; GetFoos()
          {
              return new List&lt;Foos&gt; { new Foos { FooId = 42, Name = "Fred" } };
          }
  
          [Query]
          public IEnumerable&lt;VendorDTO&gt; GetVendors()
          {
              return new List&lt;VendorDTO&gt; { new VendorDTO { VendorID = 42 } };  
          }
  
      }
  }
  </code></pre>
  
  <p>On the UI .cs file when I try and create an object of type VendorDTO I cannot. I was however able to access the Foo object from the UI Layer.</p>
  
  <p>The VendorDTO was marked as serialazble but it does however reside in a seperate project (IQUTECHDTO)</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.ComponentModel.DataAnnotations;
  using System.ComponentModel;
  using System.ServiceModel.DomainServices;
  using System.ServiceModel.Web;
  
  
  namespace IQUTechDTO
  {
      public enum LoadStatus
      {
       Initialized = 0,
       Ghost = 1,
       Loaded = 2
      }
  
      [Serializable]
      public class VendorDTO
      {
          /// &lt;summary&gt;
          ///DTO for the 'Vendor' object.
          /// &lt;/summary&gt;
  
          public VendorDTO()
          {
              this.loadStatus = LoadStatus.Initialized;
          }
  
          ///&lt;summary&gt;
          /// Copy constructor
          ///&lt;/summary&gt;
          public VendorDTO(VendorDTO sourceDTO)
          {
              loadStatus = sourceDTO.loadStatus;
              VendorID = sourceDTO.VendorID;
              VendorName = sourceDTO.VendorName;
              VendorAddress1 = sourceDTO.VendorAddress1;
              VendorAddress2 = sourceDTO.VendorAddress2;
              VendorCity = sourceDTO.VendorCity;
              VendorState = sourceDTO.VendorState;
              VendorEmail = sourceDTO.VendorEmail;
              VendorPhone = sourceDTO.VendorPhone;
              VendorPOC = sourceDTO.VendorPOC;
              VendorRegion = sourceDTO.VendorRegion;
          }
  
          public LoadStatus loadStatus;
  
          [Key]
          public int VendorID { get; set; }
          public string VendorName;
          private string VendorAddress1;
          private string VendorAddress2;
          private string VendorEmail;
          private string VendorPhone;
          private string VendorCity;
          private string VendorState;
          private string VendorPOC;
          private string VendorRegion;
  
      }
  }
  </code></pre>
  
  <p>Below is the UI Class</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Animation;
  using System.Windows.Shapes;
  using System.Windows.Navigation;
  using BusinessApplication6.Web.Services;
  using System.ServiceModel.DomainServices.Client;
  using BusinessApplication6.Web;
  
  
  namespace BusinessApplication6.Views.BOM
  {
      public partial class BOMCRUD : Page
      {
          public BOMCRUD()
          {
              InitializeComponent();
              LoadTree();
  
  
          }
  
          public void LoadTree()
          {
              BillContext newCon = new BillContext();
  
  
              //This works
              Foos fooobj = new Foos();
  
              //This doesnt work
              VendorDTO vendorobj = new VendorDTO();
  
          }
  
  
  
          // Executes when the user navigates to this page.
          protected override void OnNavigatedTo(NavigationEventArgs e)
          {
          }
  
  
  
      }
  }
  </code></pre>
  
  <p>Why will it not let me access this object.</p>
  
  <p>Your help would be greatly appreciated.</p>
  
  <p>Regards,
  Tom</p>