exchange-server - 构造函数中的 SmtpResponse 异常
问题描述
我正在将我们的垃圾邮件过滤器从 Exchange 2013 更新到 2019。我的传输代理引用了这两个 DLL:
Microsoft.Exchange.Data.Common.dll
Microsoft.Exchange.Data.Transport.dll
当我将这些 DLL 的 2013 版本替换为 Exchange 2019 中的新版本时,以下两行代码都会生成异常:
// Exchange 2019 syntax
SmtpResponse smtpResponse = SmtpResponse.Create("550", "5.7.1", "A single string");
// Exchange 2013 syntax (deprecated under 2019, but still compiles)
SmtpResponse smtpResponse = new SmtpResponse("550", "5.7.1", "A single string");
异常消息是:
Der Typeninitialisierer für "Microsoft.Exchange.Data.Transport.Smtp.SmtpResponse" hat eine Ausnahme verursacht."* ... 的类型初始化程序已生成异常。
即使是这条简单的线也会导致异常:
SmtpResponse smtpResponse = new SmtpResponse();
任何想法为什么 SmtpResponse 的构造函数会抛出此异常?在 Exchange 2013 上,此代码多年来一直完美运行。
解决方案
好的,在 Exchange Server 2019 上,Microsoft.Exchange.Data.Transport.dll
有一个新的依赖项Microsoft.Exchange.Diagnostics.dll
. 此 DLL 不像其他 DLL 那样位于 Exchange Server 的 Public 文件夹中,而是位于 bin 文件夹中。
将 Microsoft.Exchange.Diagnostics.dll 复制到我的本地 bin 文件夹解决了这个问题。
推荐阅读
- python - 创建一个 numpy 数组,其中包含 .npz 输入文件的数组列表
- android - 如何将两种信息写入nfc标签并让阅读器同时读取它们?
- javascript - React-Router 路由到类组件
- json - 如何从响应正文中获取令牌值?
- google-cloud-dataflow - 使用状态或计时器时避免重新洗牌?
- python-3.x - defaultdict 的默认值是一个带参数的 lambda 会产生错误
- javascript - 如何在 JavaScript 中记录用户提交到表单的信息
- influxdb - 响应大的influxdb查询太慢
- mysql - mysql workbench 未选择数据库 通过在侧边栏的 SCHEMAS 列表中双击其名称来选择要使用的默认数据库
- cordova - 如何在 Ionic Windows Build 中禁用 ctrl + 鼠标滚轮缩放