日期:2014-05-18  浏览次数:20834 次

Professional C# 4 amd .NET4的一个例子RoomReservation 怎么弄都不行
未能找到类型或命名空间名称“RoomServiceClient”(是否缺少 using 指令或程序集引用?)
E:\cs\RoomReservation\RoomReservationClient\MainWindow.xaml.cs

服务引用也添加了,名称是RoomReservationService
搞来搞去还是出错。
书上是第1342页(第七版)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using RoomReservationData.RoomReservationService;

namespace RoomReservationData
{
  /// <summary>
  /// MainWindow.xaml 的交互逻辑
  /// </summary>
  public partial class MainWindow : Window
  {
  public MainWindow()
  {
  InitializeComponent();
  }

  private void OnReserveRoom(object sender, RoutedEventArgs e)
  {
  var reservation = new RoomReservations()
  {
  RoomName = textRoom.Text,
  Event = textEvent.Text,
  Contact = textContact.Text,
  StartDate = DateTime.Parse(textStartTime.Text),
  EndDate = DateTime.Parse(textEndTime.Text)
  };

  var client = new RoomServiceClient();
  bool reserved = client.ReserveRoom(reservation);
  client.Close();
  if (reserved)
  MessageBox.Show("reservation ok");
  }
  }
}

------解决方案--------------------
你的代码不全,应该还有一个RoomServiceClient类的说明,找出来。