2014-10-02 65 views
0

不知道发生了什么事。简单的应用托管服务。在服务器A上运行良好。将所有内容复制到服务器B上,并突然不会启动。WCF应用程序托管服务故障状态异常?

任何提示?想法?我会很乐意提供更多信息。谢谢你的帮助。

错误消息:

的通信对象,System.ServiceModel.ServiceHost,不能用于通信 ,因为它是处于故障状态。

码(失败AT HOST.OPEN()_

static void Main(string[] args) 
     { 
      try 
      { 
       Uri baseAddress = new Uri("http://localhost:8080/Brp"); 
       Uri mexUri = new Uri("http://localhost:8080/Brp/mex"); 

       // Create the ServiceHost. 
       using (ServiceHost host = new ServiceHost(typeof(BBService), baseAddress)) 
       { 

        ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); 
        smb.HttpGetUrl = mexUri; 
        smb.HttpGetEnabled = true; 
        smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; 

        host.Description.Behaviors.Add(smb); 

        host.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); 

        BasicHttpBinding binding = new BasicHttpBinding(); 
        binding.MaxReceivedMessageSize = int.MaxValue; 
        binding.Security.Mode = BasicHttpSecurityMode.None; 

        host.AddServiceEndpoint(typeof(IBService), binding, ""); 
        // Enable metadata publishing. 

        var behavior = host.Description.Behaviors.Find<ServiceDebugBehavior>(); 
        behavior.IncludeExceptionDetailInFaults = true; 

        host.Open(); 

        Console.ReadLine(); 


        // Close the ServiceHost. 
        host.Close(); 
       } 
      } catch (Exception excep) 
      { 
       writeMessage("EXCEPTION!!! - " + excep.Message); 
      } 

回答

2

万一别人运行到这个DO:Right-click -> Run as administrator

+1

我认为这是显而易见的错误消息你得到:) – xpa1492 2014-10-02 03:01:52

0

你必须遵循一定的规则与合同留言工作时 1 。当使用消息合约类型作为参数时,只有一个参数可用于服务操作 [OperationContract] void SaveEmployeeDetails(EmployeeDetails emp);

[OperationContract] EmployeeDetails GetEmployeeDetails();

3. Service operation will accept and return only message contract type. Other data types are not allowed. 

[OperationContract的] EmployeeDetails ModifyEmployeeDetails(EmployeeDetails EMP);

注意:如果某个类型同时具有消息和数据合同,则服务操作将只接受消息合同。

相关问题