-1
我是C#世界的新手,只是擡起頭來,因爲我知道......我可能會喜歡一些新手般的東西,所以提前道歉。這是我的問題:CLR長度配額錯誤
我有一個CLR調用Web服務。從Web服務返回的數據變得太大的CLR來處理和生成以下錯誤:
Msg 6522, Level 16, State 1, Line 1
A .NET Framework error occurred during execution of user-defined routine or
aggregate "fnGetReportData":
System.Web.Services.Protocols.SoapException:The formatter threw an exception
while trying to deserialize the message: There was an error while trying to
deserialize parameter http://tempuri.org/:xmlTags.
The InnerException message was 'There was an error deserializing the object of type
System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089]]. The maximum string content
length quota (8192) has been exceeded while reading XML data. This quota may be
increased by changing the MaxStringContentLength property on the
XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position
9474.'. Please see InnerException for more details.
System.Web.Services.Protocols.SoapException:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,
object[] parameters) at myService.RequestReport(String reportName, String[] xmlTags,
String encryptedUserName, String encryptedPassword)
at myReportClr.UserDefinedFunctions.fnGetReportData(SqlString reportName,
SqlString project, SqlXml reportTags, SqlString userName, SqlString password)
我經歷了一些類似的長度配額錯誤的其他職位看,但大部分的建議包括改變應用程序配置。因爲我正在使用CLR,所以我沒有應用程序配置,我不確定是否可以添加應用程序配置。我嘗試使用LINK上的說明添加一個,但是這是針對非CLR項目的。
幫助表示感謝。提前致謝。
這裏是一段代碼來補充錯誤。
異常的SQL Server端來了下面的函數調用內:
SELECT @reportData = (dbo.fnGetReportData
('DataCompare'
,@projectName
,@harnessXmlTags
,@user
,@password)
);
下面的代碼是從C#。返回的XML過大,導致在這篇文章的頂部例外:
public static SqlXml fnGetReportData(
SqlString reportName
, SqlString project
, SqlXml reportTags
, SqlString userName
, SqlString password
)
{
String xmlResponse = " ";
SqlXml reportData = SqlXml.Null;
List<String> xmlTags = new List<String>();
xmlTags.Add(CreateTag("Project", project.ToString()));
xmlTags.Add(CreateTag("Configuration", "any"));
xmlTags.Add(reportTags.Value);
using (myService client = new myService())
{
xmlResponse =
client.RequestReport(reportName.ToString()
, xmlTags.ToArray()
, userName.ToString()
, password.ToString()
);
}
if (xmlResponse != null || !xmlResponse.Equals(""))
{
reportData = convertStringtoSqlXml(removeSoapHeader(xmlResponse, reportName.ToString()));
}
else
{
reportData = convertStringtoSqlXml(
String.Format("{0} xmlns:xsi=\"www.myReport.com/myData\" xmlns:ns=\"uri\"", reportName)
);
}
return reportData;
}
檢查 - 當你說'CLR'是指SQL Server中的CLR存儲過程嗎? – Paddy
它給出的說明不起作用? *通過更改創建XML閱讀器時使用的 XmlDictionaryReaderQuotas對象上的MaxStringContentLength屬性,可以增加此配額 * –
不確定「使用CLR」的含義。對我來說,這意味着* Common Language Runtime *,我假定C#的任何作者正在使用它。 – Jacob