我在做邮件模板发送功能时,定义了一个template.config文件,里面是这样的:
<Groups>
        <TemplateGroup TemplateGroupId="testTemplate" MailFormat="Html" Sender="ERP-FOL < [email protected] >">
            <Templates>
                <Template IsDefault="false" Locale="en-US" >
                    <Subject></Subject>
                    <File>GroupTeam/TestTemplate.htm</File>                </Template>
            </Templates>
        </TemplateGroup>
    </Groups>
然后用如下代码去读取:
using (FileStream stream = File.OpenRead(configFile))
{
//init configuration object
TemplateConfiguration configuration;
configuration = serializer.Deserialize(stream) as TemplateConfiguration;
     //validate the base folder, if set
string baseDirectory = configuration.BaseDirectory;
发现读的时候,当:Sender="ERP-FOL < [email protected] >"中有<>符号时,configuration = serializer.Deserialize(stream) as TemplateConfiguration句总是出异常,当:Sender="ERP-FOL < [email protected] >"中无<>,即写成:Sender="ERP-FOL  [email protected] "时,就能通过,但用户现在要求要有<>,请问大家怎么解决呢?谢谢!
异常错误信息如下:
未处理的“System.InvalidOperationException”类型的异常出现在 system.xml.dll 中。其他信息: XML 文档(28, 10)中有错误。