2011-10-03 24 views
5

Bunu hem linux hem de os x üzerinde denedim ve aynı sorunu yaşıyorum. Bu, Mono'nun en yeni kararlı versiyonu olan MonoDevelop 2.6'dır. Mac'imdeki v 2.10.2.MonC'de WCF Servisi erişilebilir değil mi?

Bu, birkaç gün önce benim için çalışıyordu. Tarayıcımı "http: // localhost: 8000/number/test" e yönlendiririm ve "Komut satırında, svcutil http: // localhost: 8000/number/test [somethingmore]" gibi bir şey söyleyen bir mesaj alırdım. "

Şimdi tarayıcıda Linux ve Mac üzerinde olsun mesajdır:

<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> 

a:InternalServiceFault sunucu bir iç hata isteği işleyemedi. Sunucu, istisna ayrıntılarını geri getirebilir (sunucu ayarlarına bağlıdır).

Bu çalışırdım, o yüzden önemli bir şey eksik emin değilim falan Mono ya da ne ile yanlışsa. Umarım bir fikrin vardır. Bu hemen hemen tüm MSDN eğiticilerinden (bazı değişikliklerle).

(Bilindiği üzere, şu ana kadar durumun kaydedilemediğinin farkındayım, çünkü henüz oturumlar için kurulmamış, bu hatayı aldığımda oraya ulaşmaya çalışıyordum).

İşte benim sınıfları şunlardır:

using System; 
using System.ServiceModel; 

namespace NumberService 
    { 
[ServiceContract] 
public interface INumberService 
{ 
    [OperationContract] 
    void Add(int val); 

    [OperationContract] 
    void Subtract(int val); 

    [OperationContract] 
    int Result(); 
} 
} 

using System; 

namespace NumberService 
{ 
public class NumberService : INumberService 
{ 
    private int val = 1; 


    public NumberService() 
    { 
     Console.WriteLine("NumberService created."); 
    } 

    public void Add(int val) 
    { 
     this.val += val;  
    } 

    public void Subtract(int val) 
    { 
     this.val -= val; 
    } 


    public int Result() 
    { 
     return val; 
    } 
} 
} 



using System; 
using System.ServiceModel; 
using System.ServiceModel.Description; 

namespace NumberService 
{ 
class MainClass 
{ 
    public static void Main (string[] args) 
    { 
     Uri uri = new Uri("http://localhost:8000/number/test"); 

     ServiceHost selfHost = new ServiceHost(typeof(NumberService), uri); 


     try 
     { 


      // Step 3 of the hosting procedure: Add a service endpoint. 
      selfHost.AddServiceEndpoint(
       typeof(INumberService), 
       new WSHttpBinding(SecurityMode.None), 
       "NumberService"); 


      // Step 4 of the hosting procedure: Enable metadata exchange. 
      ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); 
      smb.HttpGetEnabled = true; 
      selfHost.Description.Behaviors.Add(smb); 

      // Step 5 of the hosting procedure: Start (and then stop) the service. 
      selfHost.Open(); 
      Console.WriteLine("The service is ready."); 
      Console.WriteLine("Press <ENTER> to terminate service."); 
      Console.WriteLine(); 
      Console.ReadLine(); 

      // Close the ServiceHostBase to shutdown the service. 
      selfHost.Close(); 
     } 
     catch (CommunicationException ce) 
     { 
      Console.WriteLine("An exception occurred: {0}", ce.Message); 
      selfHost.Abort(); 
     } 


    } 


} 
} 
+0

Windows 7 üzerinde çalışır - Visual Studio VE Mono –

cevap

1

hata ayıklaması zaman hizmete erişmek için denediniz mi? InternalServiceFault'dan, hizmetinizin arızalanmasına neden olan bir şey gibi görünüyor.

Nicklas

İlgili konular