C# 协定需要双工,但绑定“BasicHttpBinding”不支持双工,或者配置不正确
我已经通过类似的问题张贴和交叉检查我的解决方案的建议。我仍然在犯以上的错误,我根本不知道这里出了什么问题。请帮忙。在my app.xml中,name和contract都是完全限定的名称,我使用binding=wsDualHttpBinding 我的app.xml文件如下所示:C# 协定需要双工,但绑定“BasicHttpBinding”不支持双工,或者配置不正确,c#,wcf,wcf-binding,C#,Wcf,Wcf Binding,我已经通过类似的问题张贴和交叉检查我的解决方案的建议。我仍然在犯以上的错误,我根本不知道这里出了什么问题。请帮忙。在my app.xml中,name和contract都是完全限定的名称,我使用binding=wsDualHttpBinding 我的app.xml文件如下所示: <?xml version="1.0"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".N
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceBehavior"
name="ABCNotificationEventService.ABCNotificationService">
<endpoint address="http://localhost:8799/ABCNotificationService"
binding="wsDualHttpBinding"
contract="ABCNotificationEventService.INotifyServiceContract">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
namespace ABCNotificationEventService
{
[ServiceContract]
public interface INotifyServiceEvents
{
[OperationContract(IsOneWay = true)]
void showErrorNotification();
[OperationContract(IsOneWay = true)]
void enableServiceStoppedNotification();
}
[ServiceContract(CallbackContract = typeof(INotifyServiceEvents))]
public interface INotifyServiceContract
{
[OperationContract]
void subscribeEvent();
[OperationContract]
void fireErrorNotifyEvent();
[OperationContract]
void fireEnableServiceStopNotifyEvent();
}
}
namespace ABCNotificationEventService
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class ABCNotificationService : INotifyServiceContract
{
static Action errorNotifyEvent = delegate { };
static Action enableServiceStopNotifyEvent = delegate { };
public void fireErrorNotifyEvent()
{
//Issue the event to the subscriber
errorNotifyEvent();
}
public void fireEnableServiceStopNotifyEvent()
{
//Issue the event to the subscriber
enableServiceStopNotifyEvent();
}
public void subscribeEvent()
{
//When subscriber calls for the SubscribeEvent Method of Publisher
//This method gets executed the and the publisher is able to store the reference to the client instance
INotifyServiceEvents subscriber = OperationContext.Current.GetCallbackChannel<INotifyServiceEvents>();
errorNotifyEvent += subscriber.showErrorNotification;
enableServiceStopNotifyEvent += subscriber.enableServiceStoppedNotification;
}
}
}
实现上述功能的类如下所示:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceBehavior"
name="ABCNotificationEventService.ABCNotificationService">
<endpoint address="http://localhost:8799/ABCNotificationService"
binding="wsDualHttpBinding"
contract="ABCNotificationEventService.INotifyServiceContract">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
namespace ABCNotificationEventService
{
[ServiceContract]
public interface INotifyServiceEvents
{
[OperationContract(IsOneWay = true)]
void showErrorNotification();
[OperationContract(IsOneWay = true)]
void enableServiceStoppedNotification();
}
[ServiceContract(CallbackContract = typeof(INotifyServiceEvents))]
public interface INotifyServiceContract
{
[OperationContract]
void subscribeEvent();
[OperationContract]
void fireErrorNotifyEvent();
[OperationContract]
void fireEnableServiceStopNotifyEvent();
}
}
namespace ABCNotificationEventService
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class ABCNotificationService : INotifyServiceContract
{
static Action errorNotifyEvent = delegate { };
static Action enableServiceStopNotifyEvent = delegate { };
public void fireErrorNotifyEvent()
{
//Issue the event to the subscriber
errorNotifyEvent();
}
public void fireEnableServiceStopNotifyEvent()
{
//Issue the event to the subscriber
enableServiceStopNotifyEvent();
}
public void subscribeEvent()
{
//When subscriber calls for the SubscribeEvent Method of Publisher
//This method gets executed the and the publisher is able to store the reference to the client instance
INotifyServiceEvents subscriber = OperationContext.Current.GetCallbackChannel<INotifyServiceEvents>();
errorNotifyEvent += subscriber.showErrorNotification;
enableServiceStopNotifyEvent += subscriber.enableServiceStoppedNotification;
}
}
}
我发现了问题。我正在使用VIX安装程序创建MSI包,配置文件没有复制到生成的MSI。因此,上述错误就来了