Error in XML document. Hexadecimal value 0x1F, is an invalid character


I worked on an issue recently where we were noticing that a large majority of the out of the box System Center Configuration manager (SCCM) reports were throwing the same error. Very odd! I would expect to see an error from a custom report but not an out of the box report! Here is the error the reports were throwing

From SQL Server Reporting Services (SSRS):

The attempt to connect to the report server failed. Check your connection information and that the report server is a compatible version.
There is an error in XML document (1, 21726).
'¬', hexadecimal value 0x1F, is an invalid character.
Line 1, position 1869.

From SCCM:

System.InvalidOperationException
There is an error in XML document (1, 21726).
 
Stack Trace:
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   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 Microsoft.ConfigurationManagement.Reporting.Internal.Proxy.ReportingService2005.GetReportParameters(String Report, String HistoryID, Boolean ForRendering, ParameterValue[] Values, DataSourceCredentials[] Credentials)
   at Microsoft.ConfigurationManagement.Reporting.Internal.SrsReportServer.GetReportParameters(String path, Dictionary`2 parameterValues, Boolean getValues)
 
-------------------------------
 
System.Xml.XmlException
'­', hexadecimal value 0x1F, is an invalid character. Line 1, position 21726.
 
Stack Trace:
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   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 Microsoft.ConfigurationManagement.Reporting.Internal.Proxy.ReportingService2005.GetReportParameters(String Report, String HistoryID, Boolean ForRendering, ParameterValue[] Values, DataSourceCredentials[] Credentials)
   at Microsoft.ConfigurationManagement.Reporting.Internal.SrsReportServer.GetReportParameters(String path, Dictionary`2 parameterValues, Boolean getValues)

Taking a look at the stack I can see that it appears to be failing to read one of the parameters (GetReportParameters)

I opened up a few of the reports in Report Builder and saw that each had a few parameters that are in every SCCM report but each had one parameter which was common to just the failing reports. The parameter was CollID. When taking a look at the query for the dataset (Parameter_DataSet_CollectionID)

select CollectionID, CollectionName=Name, NameSort=CollectionID+' - '+Name
from fn_rbac_Collection(@UserSIDs) 
order by 2

I then opened up the Function fn_rbac_Collection in the SCCM database to see what table it was pulling from. It is getting its parameters from v_Collection

I used the following SQL query to search through the parameters to find which one(s) contain the 1F hex value

SELECT Name
FROM v_Collection
WHERE CONVERT(varchar(max),convert(varbinary(max),convert(nvarchar(max),Name)),2) LIKE '%1F%'

Here is what we got:

Name
Uni-InternetExplorer_11.0¬_R01

Nothing seemed off about that name so I pasted it into notepad and started keying through the letters. I noticed that going from left to right, when I key past the zero in 11.0, I had to click the arrow key twice on my keyboard! Opening the string in a hex editor I could see that right between that zero and the underscore is that 1F hex.

Knowing now that it was the culprit, we went into SCCM, found that collection, and then retyped it so that it would no longer have that hidden character.

Kicked off the report and we had a successful render!

In other cases, I also came across reports that had the same issue, but were pulling from Assignments. This is the query I used to pull the corrupt assignment parameters

SELECT AssignmentName
FROM CI_CIAssignments
WHERE CONVERT(varchar(max),convert(varbinary(max),convert(nvarchar(max),AssignmentName)),2) LIKE '%1F%'

Mark Hughes
Microsoft Business Intelligence Support – Escalation

Comments (6)

  1. Alvaro Paredes says:

    Hi Mark,

    Same issue here last week, I would like to share with you a Procedure that me and my team came across in order to find the Table/Column/Value straight from the Instance, in a handy way:

    social.technet.microsoft.com/.../31234.invalid-character-0x1f-error-on-reports-system-center-configuration-manager.aspx

    You are welcome if you want to add it on your post.

  2. Rich Mawdsley says:

    Hi Mark,

    We've just experienced the same. Mind blown. What the hell! After running the query and getting the collection name (which awkwardly had my name in it).. as you say pressing the arrow key across almost stumbled on 1 character. Copied and pasted the name into Notepad++ and it shows a "US" that was there hidden away in its own little black hole!

    Crazy!

    Reporting is now working again. Well done and thankyou!

    Rich

  3. Peter Holter-Andersen says:

    Hi,

    Had this same issue. Turned out one of my device groups had a name containing an 0x1F character. Found it using this webpage. Gave it the same name, and ow the reports are working again. Weird world we live in 😀

    Cheers,

    Peter

  4. Bob Estopa says:

    Hello thank you very much, only was replace the correct single quotes:

    SELECT Name
    FROM v_Collection
    WHERE CONVERT(varchar(max),convert(varbinary(max),convert(nvarchar(max),Name)),2) LIKE '%1F%'

    is not the same that ‘%1F%’

    And then i found error in one of collections, replace the character and the problem has gone!

    Regards!

    1. Bob Estopa says:

      The error is in the process of copy/paste...........................LOL

  5. Lukas says:

    For me it was a special ASCII character 30 (Record Separator) in the text of the field I was returning. I just added a replace([text], char(30)) to get rid of it. It is not a printable character so it isn't necessary to display it.

Skip to main content