简体   繁体   中英

Self-Hosting WCF and System.ServiceModel.FaultException

I have a simple WCF Service Library Project (call this Project W) with a handful of DLLs in directory X. I set the startup directory of W to X, all methods work correctly using WcfServiceHost in Visual Studio 2010.

I want to self-host W, so, I created a console Project (call this Project C), added a reference to W, set the startup directory of W to X, then have essentially the following main lines of code

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

When I now test the methods in W, I am getting System.ServiceModel.FaultException with {"The specified module could not be found. (Exception from HRESULT: 0x8007007E)"} .

What can this mean? How can I tell what module it is trying to load?

I am fairly new to both C# and WCF, any hint would be apprecited.

You can subscribe to event AppDomain.AssemblyResolve and see in the debugger, which assembly is problematic.

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

...

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

You need to determine if this error is in the service or the client.

From the error message it seems this is a service side error. You could implement IErrorHandler from http://msdn.microsoft.com/en-us/library/gg281715.aspx .

This will give you access to all errors in your service. You can then log all exceptions and their inner exceptions.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM