简体   繁体   English

加载XML文件时服务器无法处理请求错误

[英]Server unable to process request error when loading XML file

I am trying to read from an XML file and when I try and load it using an XmlDocument I get this error: 我正在尝试从XML文件读取内容,当我尝试使用XmlDocument加载它时,出现此错误:

The server was unable to process the request due to an internal error. 由于内部错误,服务器无法处理请求。 For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. 有关错误的更多信息,请打开服务器上的IncludeExceptionDetailInFaults (来自ServiceBehaviorAttribute<serviceDebug>配置行为),以便将异常信息发送回客户端,或者根据Microsoft .NET Framework打开跟踪。 SDK文档并检查服务器跟踪日志。

Here is the code that causes this: 这是导致此的代码:

public string calorieCount(int choice)
  {
    string calCount = "250";
    XmlDocument doc = new XmlDocument();

    //ERROR WITH LINE BELOW. no error without.
    doc.LoadXml("XMLFile1.xml");

    //XmlElement root = doc.DocumentElement;
    //XmlNode node = doc.SelectSingleNode("/menu/item[@name='Burger']/calories");
    //string checker = node.Value;
    //MessageBox.Show(checker);
    return calCount;
}

It seems as though no matter what path I place in there it doesn't work. 似乎无论我放置在哪条路径上都行不通。 Any ideas? 有任何想法吗?

EDIT I have done the following and the error persists, I have updated the service reference and it still gives me this error. 编辑我已经完成了以下操作,并且错误仍然存​​在,我更新了服务引用,但它仍然给我这个错误。

<behavior name="debug">
      <serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>

and

<services>
 <service name="calorieCount" behaviorConfiguration="debug"></service>
</services>

Do just as the error message says. 按照错误消息所述进行操作。

Add to your service - 添加到您的服务-

 <services>
      <service name="YourServiceName" behaviorConfiguration="debug">
  </services>

Add to your config file 添加到您的配置文件

<serviceBehaviors>
  <behavior name="debug">
    <serviceDebug includeExceptionDetailInFaults="true" />
  </behavior>
</serviceBehaviors>

EDIT : 编辑

  1. If this doesn't fix your issue, turn the tracing on. 如果这不能解决您的问题,请打开跟踪。
  2. Ensure service name has full name eg: Namespace.ClassName 确保服务名称具有全名,例如:Namespace.ClassName
  3. Ensure contract has full name eg: Namespace.ClassName 确保合同具有全名,例如:Namespace.ClassName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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