问题描述
使用SymmetricSecurityBindingElement进行令牌认证,代码如下:提示无法创建通道BindingElementCollectionbec=newBindingElementCollection();bec.Insert(0,newTransactionFlowBindingElement());bec.Insert(1,newReliableSessionBindingElement());bec.Insert(2,SecurityBindingElement.CreateSspiNegotiationBindingElement(true));bec.Insert(3,newTcpTransportBindingElement());returnnewCustomBinding(bec);改为:正常了BindingElementCollectionbec=newBindingElementCollection();bec.Insert(0,newTransactionFlowBindingElement());bec.Insert(1,newReliableSessionBindingElement());bec.Insert(2,SecurityBindingElement.CreateSspiNegotiationBindingElement(true));bec.Insert(3,newHttpTransportBindingElement());returnnewCustomBinding(bec);wcf中使用nettcp,不能使用令牌吗?若能使用,请代码示例下,先谢了以上代码根据:https://msdn.microsoft.com/en-us/library/system.servicemodel.channels.symmetricsecuritybindingelement.aspx中介绍的方法:ToaddthisclasstoabindingCreateaBindingElementCollection.Createcustombindingelementsthatisabovethisbindingelementinthebindingstack,suchastheoptionalTransactionFlowBindingElementandReliableSessionBindingElement.Addthecreatedelements,intheordermentionedpreviously,totheBindingElementCollectionusingtheInsertItemmethod.CreateaninstanceofSymmetricSecurityBindingElementandaddittothecollection.Addanyadditionalcustombindingelementstothecollection,suchasTcpTransportBindingElement.加入的顺序应该没有问题。
解决方案
本帖最后由 ywscr0000 于 2015-10-06 13:44:05 编辑
解决方案二:
自己项!!!!!