Resolve "an invalid character was found in text content' error when opening a report in Report Portal and when launching Message Designer in Portrait Dialogue

If there is a hidden character (e.g. a non-printing ASCII character) in a message template name, this prevents certain reports from running in Report Portal in Visual Dialogue.
The following error appears:
User-added image

After pressing 'Ctrl+Shift+E' then the detailed error message shows:

Base exception:
BaseException message: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Runtime.InteropServices.COMException: An invalid character was found in text content at MHDialogServer.MHReportAPIClass.GetParamLookupDataset(String ServerSession, Int32 ReportParamID) at MH.DialogServerApi.WebServices.ReportAPIService.GetParamLookupDataset(String ServerSession, Int32 ReportParamID) in d:\Build\467\Sources\DotNet\DialogServerApi\WebServices\ReportAPIService.cs:line 311 --- End of inner exception stack trace ---
BaseException source: System.Web.Services

This can also show up opening message templates.
When opening a Template or a Master Template in Message Designer the following error occurs:

User-added image

To find out which template is causing the problem, the following query can be executed against the SQL Server database:
SELECT dbm_id, dbm_name
FROM doc_base_message, doc_type, channel_type
WHERE dbm_doct_id = doct_id
AND doct_ct_id = ct_id
AND ct_name = N'EMAIL'
ORDER BY dbm_name

Save the results as a .csv (comma delimited) file and open them in a text editor like Notepad++
There is simple way to check if message templates names are correct: If there are non-printing ASCII characters found in any of the template names then these are the templates that must be renamed.

Note that you should also check if there are any hidden characters in names of other elements such as names of selections.
If the problem occurs, but it does not affect every message template, then it is probably a non-printing character in one(or more) of the selection records
Run this query if there seems to be nothing wrong with the template names
This is an easy approach, because it leaves out 2 very complicated fields (SEL_EXPRESSION & SEL_SQL).  
If this doesn't show anything, then it is best to make a backup of the SELECTION table, and restore it to a 6.1.4 instance.  

You can create table script along with its data using following steps:

  1. Right click on the database.
  2. Select Tasks > Generate scripts ...
  3. Click next.
  4. Click next.
  5. Set Scripting Options / Advanced / Types of data to script
    1. It's set to Schema only by default, 
    2. You need to choose Data only
  6. Select the Tables checkbox and click next.
  7. Select your table name and click next.
  8. Click next until the wizard is done.
There is code in PD 6.1.4 that will pinpoint in the log files exactly which record in which table is causing the problem.
UPDATED:  October 13, 2017