[英]Server unable to process request error when loading XML file
我正在嘗試從XML文件讀取內容,當我嘗試使用XmlDocument
加載它時,出現此錯誤:
由於內部錯誤,服務器無法處理請求。 有關錯誤的更多信息,請打開服務器上的
IncludeExceptionDetailInFaults
(來自ServiceBehaviorAttribute
或<serviceDebug>
配置行為),以便將異常信息發送回客戶端,或者根據Microsoft .NET Framework打開跟蹤。 SDK文檔並檢查服務器跟蹤日志。
這是導致此的代碼:
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;
}
似乎無論我放置在哪條路徑上都行不通。 有任何想法嗎?
編輯我已經完成了以下操作,並且錯誤仍然存在,我更新了服務引用,但它仍然給我這個錯誤。
<behavior name="debug">
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
和
<services>
<service name="calorieCount" behaviorConfiguration="debug"></service>
</services>
按照錯誤消息所述進行操作。
添加到您的服務-
<services>
<service name="YourServiceName" behaviorConfiguration="debug">
</services>
添加到您的配置文件
<serviceBehaviors>
<behavior name="debug">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
編輯 :
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.