本文介绍了Endpoint 与 windows 沉浸式项目的版本 1 不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
For some reason I have error generating code for a wcf service using "Add service reference" wizard.
Custom tool warning: No endpoints compatible with version 1 of windows immersive project were found. C:work est_projectsCirMetroService ReferencesSvcProxyReference.svcmap 1 1 CirMetro
Do you guys know how to fix it ?
My sample WCF service is braindead simple. Here is source code:
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");
}
解决方案
I figured it out.
It's unfortunate that we have to decompile sources of Visual Studio to find out what works in Metro instead of referring to non-existent documentation :-)
In short I can't use ReliableSession.
If you want more details C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDEPrivateAssembliesMicrosoft.VisualStudio.ServiceReference.Platforms.dll
contains function which check what is supported.
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;
}
这篇关于Endpoint 与 windows 沉浸式项目的版本 1 不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!