如何在代码中设置IncludeExceptionDetailInFaults不使用App.Config中?设置IncludeExceptionDetailInFaults为true,代码WCF
62
A
回答
95
是的,没错 - 你打开服务主机上的服务器端,之前。然而,这将需要您自托管的WCF服务 - 不会在IIS托管方案的工作:如果你需要做同样的事情在IIS托管
ServiceHost host = new ServiceHost(typeof(MyWCFService));
ServiceDebugBehavior debug = host.Description.Behaviors.Find<ServiceDebugBehavior>();
// if not found - add behavior with setting turned on
if (debug == null)
{
host.Description.Behaviors.Add(
new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
}
else
{
// make sure setting is turned ON
if (!debug.IncludeExceptionDetailInFaults)
{
debug.IncludeExceptionDetailInFaults = true;
}
}
host.Open();
,你必须创建自己的定制MyServiceHost
后裔和合适的MyServiceHostFactory
,将实例化这样的定制服务宿主,并在* .svc文件引用该定制服务主机工厂。
26
您还可以在上面类声明的[ServiceBehavior]标签继承接口
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class MyClass:IMyService
{
...
}
相关问题
- 1. WCF IncludeExceptionDetailInFaults编程?
- 2. serviceDebug includeExceptionDetailInFaults =“true” - 在活动网站上
- 3. 将页面异步模式设置为true从代码隐藏
- 4. 代码中的WCF设置vs app.config
- 5. WCF代理设置
- 6. 设置aspNetCompatibilityEnabled为true抛出MethodAccessException基于JSON WCF服务
- 7. 不ManualResetEvent的设置为true
- 8. 如何设置OnClientClick为true?
- 9. VS代码设置为C++
- 10. 检查值是否设置为true并且为true true
- 11. 如何将WCF IncludeExceptionDetailInFaults添加到端点行为?
- 12. 我应该怎么设置<PrintWhenExperssion> true值或Java代码
- 13. 为什么HasLoadedOrAssignedValue属性设置为true?
- 14. 为什么设置Autocommit为true?
- 15. 当autopostback必须设置为true(包含代码)时,无回传的Dropdownlist
- 16. 即使“files.insertFinalNewline”设置为true,VS代码也不插入最终的新行
- 17. 当incrementalCompileWarnings标志设置为true时,“没有源代码可用于类型”
- 18. 通过代码设置宽度为wrap_content为TextView通过代码
- 19. 在osCommerce中将所有单选按钮设置为true或false,或者仅将true设置为true?
- 20. 设置ItemContainerStyle代码
- 21. 设置从代码
- 22. 打开IncludeExceptionDetailInFaults
- 23. 如何动态设置密码属性为EditTextPreference,如android:password =“true”?
- 24. WCF - AsyncPattern = true或IsOneWay = true
- 25. 如果它是IsOneWay = true,则不会调用WCF服务代码
- 26. StAX - 如何将XMLInputFactory.IS_VALIDATING设置为true?
- 27. 运行时错误设置为true
- 28. 设置asp:PlaceHolder与jQuery可见为true
- 29. 设置ToolStripMenuItem.Visible为true不起作用
- 30. 如何将AIRPLANE_MODE_ON设置为“True”或ON?
保存到本地命名管道WCF应用VS正在运行的服务我的生活设置。谢谢 ! – Larry 2011-07-21 12:19:19
这段代码会进入什么文件? – 2012-05-24 14:46:45