获取ArgumentException“使用Enterprise Library Email Trace Listener时,参数'address'不能是空字符串”

时间:2016-05-30 07:00:52

标签: c#

我正在使用Enterprise Library 6.0。当我使用电子邮件跟踪侦听器时,我得到ArgumentException

  

参数'address'不能是空字符串。

我的配置:

<add name="Email Trace Listener" 
     type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
     listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
     toAddress="testemail1@test.org;testemail2@test.org;" 
     subjectLineStarter="IMD.PP" 
     subjectLineEnder="Local" 
     fromAddress="testfrom@test.org" 
     smtpServer="smtpserver.test.org" 
     formatter="Text Formatter" />

1 个答案:

答案 0 :(得分:3)

原因是在toAddress末尾有一个额外的分号,当我删除那个分号时,它开始工作:

<add name="Email Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" toAddress="testemail1@test.org;testemail2@test.org" subjectLineStarter="IMD.PP" subjectLineEnder="Local" fromAddress="testfrom@test.org" smtpServer="smtpserver.test.org" formatter="Text Formatter" />