2014-10-02 104 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);

注意:如果某個類型同時具有消息和數據合同,則服務操作將只接受消息合同。

相關問題