c# - 使用企业库电子邮件跟踪监听器时获取 ArgumentException "The parameter ' 地址'不能为空字符串"

标签 c#

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

The parameter 'address' cannot be an empty string.

我的配置:

<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" />

最佳答案

原因是 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" />

关于c# - 使用企业库电子邮件跟踪监听器时获取 ArgumentException "The parameter ' 地址'不能为空字符串",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37519469/

相关文章:

c# - 使用剪切或复制从剪贴板粘贴文件

c# 动态调用方法与表达式树

c# - 如何通过 Redis 服务器转换具有多种数据类型的 MemoryStream

c# - 如何合并拆分为 2 个具有奇数和偶数索引的数组?

c# - 在数据库中生成测试数据的任何工具

c# - Scaffold-DbContext SQL View ? ASP 网络核心 3.1

c# - 将对象 [] 传递给参数对象 [] 不起作用

c# - 如何确定远程处理 channel 是否已注册

c# - 忽略异步任务方法的返回值

c# - 在 WiX 中安装期间创建临时文件夹