Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从WCF中的SOAP请求中删除VsDebuggerCausalityData头部分_Wcf_Soap_.net 3.5_Wcf Security - Fatal编程技术网

如何从WCF中的SOAP请求中删除VsDebuggerCausalityData头部分

如何从WCF中的SOAP请求中删除VsDebuggerCausalityData头部分,wcf,soap,.net-3.5,wcf-security,Wcf,Soap,.net 3.5,Wcf Security,我补充说 <system.diagnostics> <switches> <add name="Remote.Disable" value="1" /> </switches> </system.diagnostics> 到我的app.config,但SOAP客户端仍会生成标头 我正在将custombinding与messageversion Soap11和httpstransport集一起使用 有没有简

我补充说

 <system.diagnostics>
   <switches>
     <add name="Remote.Disable" value="1" />
   </switches>
 </system.diagnostics>

到我的app.config,但SOAP客户端仍会生成标头

我正在将custombinding与messageversion Soap11和httpstransport集一起使用


有没有简单的方法删除它?

当您的配置打开wcf跟踪或日志记录时,会添加标题。关闭它们,将不会发送此消息。

请尝试在Visual studio中禁用对WCF的调试器支持

运行此命令以卸载-vsdiag_regwcf.exe-u

它位于
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\

可以使用-i参数重新安装调试器支持,也可以使用-s参数检查是否启用了调试器支持


有关更多详细信息,请参阅。

我通过手动删除负责将vscasualitydata放入的行为来解决此问题

        var vs = srv.Endpoint.Behaviors.Where((i) => i.GetType().Namespace.Contains("VisualStudio"));
        srv.Endpoint.Behaviors.Remove((System.ServiceModel.Description.IEndpointBehavior)vs.Single());
根据
@Luiz Felipe
给出的“有效”答案,我提出了一个略为稳健的解决方案:

var vs = client.Endpoint.EndpointBehaviors.FirstOrDefault((i) => i.GetType().Namespace == "Microsoft.VisualStudio.Diagnostics.ServiceModelSink");
if (vs != null)
{
    client.Endpoint.Behaviors.Remove(vs);
}

配置中没有设置跟踪或日志记录。如果它是默认打开的,我如何将其关闭?它是否仅在调试模式下运行时发生,还是在编译以供发布并在VS外部运行exe时发生?它不会在VS外部发生。是否有方法在调试时将其关闭?如果它在VS中甚至在发布模式下发生,并且对于相同的.config,它不会在VS外部发生,我看不到禁用它的方法。因为额外的头似乎只在调试模式下添加,所以您也可以将此代码包装在编译器预处理器指令中,这样代码只添加到调试版本,即。
\if debug
<代码>#endif