C# CLR长度配额错误

C# CLR长度配额错误,c#,.net,C#,.net,我对C#world还不熟悉,只是给了一个提示,因为我知道…我可能会去一些新手一样的东西,所以提前道歉。我的问题是: 我有一个调用web服务的CLR。从web服务返回的数据太大,CLR无法处理,并生成以下错误: Msg 6522, Level 16, State 1, Line 1 A .NET Framework error occurred during execution of user-defined routine or aggregate "fnGetReportData":

我对C#world还不熟悉,只是给了一个提示,因为我知道…我可能会去一些新手一样的东西,所以提前道歉。我的问题是:

我有一个调用web服务的CLR。从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,所以我没有应用程序配置,也不确定是否可以添加应用程序配置。我尝试使用上的说明添加一个,但这是针对非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;
    } 
公共静态SqlXml fnGetReportData(
SqlString报告名
,SqlString项目
,SqlXml reportTags
,SqlString用户名
,SqlString密码
)
{
字符串xmlResponse=“”;
SqlXml reportData=SqlXml.Null;
List xmlTags=新列表();
Add(CreateTag(“Project”,Project.ToString());
Add(CreateTag(“配置”、“任何”);
添加(reportTags.Value);
使用(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());
}
其他的
{
reportData=convertStringtoSqlXml(
String.Format(“{0}xmlns:xsi=\”www.myReport.com/myData\”xmlns:ns=\”uri\”,reportName)
);
}
返回报告数据;
} 

您的web.config或app.config中有一个名为
MaxStringContentLength
的设置需要增加。如果没有,则使用默认设置,您需要添加它。MSDN在配置文件中的何处添加它有很好的文档。

要检查-当您说“一个CLR”时,您是指SQL server中的一个CLR存储过程吗?它给出的指令是否无效?可以通过更改创建XML读取器时使用的XmlDictionaryReaderQuotas对象的MaxStringContentLength属性来增加此配额。不确定“使用CLR”是什么意思。对我来说,这意味着公共语言运行时,我假设C#的任何编写器都在使用它。请参见,您是否有一个示例,说明您试图执行的代码会出现此异常?如果你是C语言的新手,可能更容易让人联想到上面的文章#