C# WCF客户端应用程序挂起

C# WCF客户端应用程序挂起,c#,wcf,C#,Wcf,我是WCF技术的新手。我目前的问题是,我的windows窗体应用程序没有收到wcf程序的响应。以下是我的windows窗体应用程序的代码: WCFService.PMSService obj = new WCFService.PMSService(); string xx = obj.Test("Hello"); MessageBox.Show(xx); 我的windows窗体应用程序挂起在这行->字符串xx=obj.Test(“Hello”) 以下是wcf my程序的代码: 接口

我是WCF技术的新手。我目前的问题是,我的windows窗体应用程序没有收到wcf程序的响应。以下是我的windows窗体应用程序的代码:

WCFService.PMSService obj = new WCFService.PMSService();      
string xx = obj.Test("Hello");
MessageBox.Show(xx);
我的windows窗体应用程序挂起在这行->字符串xx=obj.Test(“Hello”)

以下是wcf my程序的代码:

接口/声明页 实现页面 有人知道可能的原因吗

对于刚接触WCF的人来说,最好的建议(也许是显而易见的,很多人都忽略了)是熟悉WCF跟踪和消息日志。WCF跟踪功能提供了一种相对简单的内置方法来监视与WCF服务之间的通信。对于测试和调试环境,请配置信息性或详细的活动跟踪,并启用消息日志记录。在最初部署和测试新服务或向现有服务添加新操作和/或通信绑定时,活动跟踪和消息日志记录的组合应该是有益的

以下链接提供了一个很好的概述:


您是如何托管服务的?例如,您使用的是IIS还是控制台应用程序?服务的绑定和端点配置在哪里?@Alberto IIS。以下是配置设置:您是否尝试将调试器附加到该服务,或使用Fiddler或其他方法来验证您是否确实正在访问该服务?我也会尝试您的建议。我会随时通知你的。
 // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IPMSService
    {
        [OperationContract]
        string DetermineGender(PersonalInfo pInfo);

        [OperationContract]
        string Test(string val);
    }

    [DataContract]
    public enum Gender
    {
        [EnumMember]
        Male,
        [EnumMember]
        Female,
        [EnumMember]
        None
    }

    // Use a data contract as illustrated in the sample below to add composite types to service operations
    [DataContract]
    public class PersonalInfo
    {
        [DataMember]
        public string name
        {
            get { return name; }
            set { name = value; }
        }

        [DataMember]
        public string surname
        {
            get { return surname; }
            set { surname = value; }
        }

        [DataMember]
        public string idNo
        {
            get { return idNo; }
            set { idNo = value; }
        }
 // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class PMSService : IPMSService
    {
        public string DetermineGender(PersonalInfo pInfo)
        {
            Gender Result = Gender.None;

            int idNo = Convert.ToInt32(pInfo.idNo.Substring(6, 4));

            if (idNo >= 5000)
                Result = Gender.Male;
            else
                Result = Gender.Female;

            return Result.ToString();
        }

        public string Test(string val)
        {
            return "U passed " + val;
        }
    }