【问题标题】:Self-Hosting WCF and System.ServiceModel.FaultException自承载 WCF 和 System.ServiceModel.FaultException
【发布时间】:2013-02-21 18:58:46
【问题描述】:

我有一个简单的 WCF 服务库项目(称为项目 W),在目录 X 中有几个 DLL。我将 W 的启动目录设置为 X,所有方法在 Visual Studio 2010 中使用 WcfServiceHost 都可以正常工作。

我想自己托管W,所以,我创建了一个控制台项目(称为项目C),添加了对W的引用,将W的启动目录设置为X,然后基本上有以下几行代码

var host = new ServiceHost(typeof(EvalService));
host.Open();

当我现在测试 W 中的方法时,我得到了 System.ServiceModel.FaultException{"The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}

这意味着什么?我怎样才能知道它正在尝试加载哪个模块?

我对 C# 和 WCF 都很陌生,任何提示都会受到赞赏。

【问题讨论】:

  • 在.Net SDK中使用fuslogvw.exe
  • 谢谢,@rene,在 fuslogvw.exe 中没有任何显示,还有其他想法吗?
  • 可能是缺少的非 .Net dll,尝试ProcessExplorer 并在结果列中查找 FAILED。

标签: c# wcf self-hosting faultexception


【解决方案1】:

您可以订阅事件 AppDomain.AssemblyResolve 并在调试器中查看哪个程序集有问题。

AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += OnAssemblyResolve;

...

private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
{
   Console.WriteLine(args.RequestingAssembly); //set breakpoint there
   return null;
}

【讨论】:

    【解决方案2】:

    您需要确定此错误是在服务中还是在客户端中。

    从错误消息看来,这是一个服务端错误。您可以从http://msdn.microsoft.com/en-us/library/gg281715.aspx 实现 IErrorHandler。

    这将使您能够访问服务中的所有错误。然后,您可以记录所有异常及其内部异常。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-21
      • 2015-08-25
      相关资源
      最近更新 更多