3

I have a WCF service that has been running for a long time now. I recently made some changes and it works fine locally but crashes with this message server side (only for the method that I changed, all other methods work fine)

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.

The problem is I have no way to debug the problem as it is only failing on the server. More frustrating, I know exactly where the code is failing I just can't tell why because I can never pull the exception data. Here is the method that is being hit in the WCF service.

    public bool GenerateSpec(string product)
    {
        specService.GenerateSpec(product);
        return true;
    }

Which then calls this.

    public bool GenerateSpec(string productNumber)
    {
        try
        {
            SessionFactory factory = new SessionFactory();
            Session = factory.CreateSession(DataConnection.PM);
            productService = new ProductService(Session);

            // other code
            return true;
        }
        catch (Exception e)
        {
            emailService.SendMessage(e.Message + "\n\n" + e.StackTrace);
            return false;
        }
    }

I know it fails at the Session = factory.CreateSession(DataConnection.PM); line but don't know why and it seems to just be ignoring my try catch block and dying anyways. What could be going on?

4

3 回答 3

1

您可以设置您的 Web.Config,以便将服务器端异常详细信息返回给客户端,这样您就可以看到真正的异常。

在你的 serviceBehavior 中,尝试设置

<serviceDebug includeExceptionDetailInFaults="True" />

于 2013-07-25T00:03:12.393 回答
1

你确定这条线:

emailService.SendMessage(e.Message + "\n\n" + e.StackTrace);

是不是在服务器上抛出异常?它可能会到达您的 try catch 块,但会在此行引发另一个异常。

于 2013-07-24T16:09:52.850 回答
0

这看起来好像找不到方法。使用 Fiddler 查看调用返回的内容。

于 2013-07-24T18:36:29.547 回答