2012-02-21 41 views
3

出於某種原因,我使用「添加服務引用」嚮導生成wcf服務的代碼時出錯。端點與Windows沉浸式項目的版本1不兼容

Custom tool warning: No endpoints compatible with version 1 of windows immersive project were found. C:\work\test_projects\CirMetro\Service References\SvcProxy\Reference.svcmap 1 1 CirMetro 

你們知道如何解決它嗎?

我的示例WCF服務是braindead簡單。這裏是源代碼:

static void Main() 
{ 
    UiWcfSession.OnInitialize += ClientInitialize; 

    var baseAddresses = new Uri("net.tcp://localhost:9000/"); 

    var host = new ServiceHost(typeof(UiWcfSession), baseAddresses); 

    var reliableSession = new ReliableSessionBindingElement { Ordered = true, InactivityTimeout = new TimeSpan(24, 20, 31, 23) }; 
    var binding = 
     new CustomBinding(reliableSession, new TcpTransportBindingElement()) { ReceiveTimeout = TimeSpan.MaxValue }; 

    host.AddServiceEndpoint(typeof(IClientFulfillmentPipeService), binding, "svc"); 

    var metadataBehavior = new ServiceMetadataBehavior(); 
    host.Description.Behaviors.Add(metadataBehavior); 
    var mexBinding = MetadataExchangeBindings.CreateMexTcpBinding(); 
    host.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, "mex"); 

    host.Open(); 

    Thread.CurrentThread.Join(); 
} 

private static void ClientInitialize(int uiprocessid, string key) 
{ 
    Debug.WriteLine("ClientInitialize"); 
} 
+0

有一個[文章](http://blogs.msdn.com/b/piyushjo/archive/2011/10/19/wcf-for-metro-apps-supported-functionality.aspx)告訴WPF Metro應用程序支持哪些WCF子集。 – 2012-02-21 05:34:56

+0

我讀過這篇文章。它首先在Google搜索中彈出:)爲了修復它,我需要在代碼中更改哪些內容?因爲它說Metro支持我正在使用的TcpBinding。 – expert 2012-02-21 05:38:51

+0

嘗試使用Http MEX綁定 – 2012-02-21 05:45:42

回答

6

我想通了。

這是不幸的是,我們要反編譯的Visual Studio的來源,以找出地鐵是什麼在起作用,而不是指不存在的文件:-)

總之我不能使用的ReliableSession。

如果你想了解更多的細節C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.ServiceReference.Platforms.dll包含檢查什麼是支持的功能。

private static bool IsBindingSupported(Binding binding) 
{ 
    if ((!(binding is BasicHttpBinding) && !(binding is CustomBinding)) && (!(binding is WSHttpBinding) && !(binding is NetTcpBinding))) 
    { 
     return false; 
    } 
    if (binding is WSHttpBinding) 
    { 
     if (((WSHttpBinding) binding).ReliableSession.Enabled) 
     { 
      return false; 
     } 
     if (((WSHttpBinding) binding).TransactionFlow) 
     { 
      return false; 
     } 
     if (((WSHttpBinding) binding).MessageEncoding != WSMessageEncoding.Text) 
     { 
      return false; 
     } 
    } 
    if (binding is NetTcpBinding) 
    { 
     if (((NetTcpBinding) binding).ReliableSession.Enabled) 
     { 
      return false; 
     } 
     if (((NetTcpBinding) binding).TransactionFlow) 
     { 
      return false; 
     } 
    } 
    foreach (BindingElement element in binding.CreateBindingElements()) 
    { 
     if (element is TransportBindingElement) 
     { 
      if ((!(element is HttpTransportBindingElement) && (!(element is HttpsTransportBindingElement) || (element as HttpsTransportBindingElement).RequireClientCertificate)) && !(element is TcpTransportBindingElement)) 
      { 
       return false; 
      } 
     } 
     else if (element is MessageEncodingBindingElement) 
     { 
      if (!(element is BinaryMessageEncodingBindingElement) || (((BinaryMessageEncodingBindingElement) element).MessageVersion != MessageVersion.Soap12WSAddressing10)) 
      { 
       if (element is TextMessageEncodingBindingElement) 
       { 
        if ((((TextMessageEncodingBindingElement) element).MessageVersion != MessageVersion.Soap11) && (((TextMessageEncodingBindingElement) element).MessageVersion != MessageVersion.Soap12WSAddressing10)) 
        { 
         return false; 
        } 
       } 
       else 
       { 
        return false; 
       } 
      } 
     } 
     else if (element is SecurityBindingElement) 
     { 
      if (!(element is TransportSecurityBindingElement)) 
      { 
       return false; 
      } 
      TransportSecurityBindingElement element2 = (TransportSecurityBindingElement) element; 
      if (!ValidateUserNamePasswordSecurityBindingElement(element2)) 
      { 
       if (((((element2.EndpointSupportingTokenParameters.Endorsing.Count == 1) && (element2.EndpointSupportingTokenParameters.Signed.Count == 0)) && ((element2.EndpointSupportingTokenParameters.SignedEncrypted.Count == 0) && (element2.EndpointSupportingTokenParameters.SignedEndorsing.Count == 0))) && ((element2.EndpointSupportingTokenParameters.Endorsing[0] is SecureConversationSecurityTokenParameters) && ((element2.MessageSecurityVersion == MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10) || (element2.MessageSecurityVersion == MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10)))) && ((element2.IncludeTimestamp && (element2.DefaultAlgorithmSuite == SecurityAlgorithmSuite.Default)) && (element2.SecurityHeaderLayout == SecurityHeaderLayout.Strict))) 
       { 
        SecureConversationSecurityTokenParameters parameters = (SecureConversationSecurityTokenParameters) element2.EndpointSupportingTokenParameters.Endorsing[0]; 
        if (parameters.RequireDerivedKeys || !(parameters.BootstrapSecurityBindingElement is TransportSecurityBindingElement)) 
        { 
         return false; 
        } 
        TransportSecurityBindingElement bootstrapSecurityBindingElement = (TransportSecurityBindingElement) parameters.BootstrapSecurityBindingElement; 
        if (!ValidateUserNamePasswordSecurityBindingElement(bootstrapSecurityBindingElement)) 
        { 
         return false; 
        } 
       } 
       else 
       { 
        return false; 
       } 
      } 
     } 
     else if ((!(element is SslStreamSecurityBindingElement) || (element as SslStreamSecurityBindingElement).RequireClientCertificate) && !(element is WindowsStreamSecurityBindingElement)) 
     { 
      if (!(element is TransactionFlowBindingElement)) 
      { 
       return false; 
      } 
      if ((!(binding is WSHttpBinding) || ((WSHttpBinding) binding).TransactionFlow) && (!(binding is NetTcpBinding) || ((NetTcpBinding) binding).TransactionFlow)) 
      { 
       return false; 
      } 
     } 
    } 
    return true; 
}