microsoft / microsoft/sqlmanagementobjects

NullReferenceException with Microsoft.Data.SqlClient 5.2.0 and with event handler for Backup.PercentComplete

未关闭
#162 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
143
派生
28
PR 合并指标
30 天内没有已合并 PR

描述

In our app we reference both NuGet-Packages Microsoft.SqlServer.SqlManagementObjects and Microsoft.Data.SqlClient.
We use SMO for many DB-related tasks, incl. Backup of the app databases.
We refresh the NuGet references regularly, actually we use Microsoft.SqlServer.SqlManagementObjects 171.30.0 and Microsoft.Data.SqlClient 5.1.5.
Everything worked fine until we updated Microsoft.Data.SqlClient to the actual version 5.2.0. Now our backup code throws NullReferenceException. As a workaround we switched back to Microsoft.Data.SqlClient 5.1.5.
We were able to reproduce the issue with the sample from https://learn.microsoft.com/en-us/sql/relational-databases/server-management-objects-smo/tasks/backing-up-and-restoring-databases-and-transaction-logs?view=sql-server-ver16#backing-up-databases-and-transaction-logs-in-visual-c
The only difference is the added event handler for Backup.PercentComplete. With it, the sample throws NullReferenceException when calling Backup.SqlBackup() and using SqlClient 5.2.0. The same code works fine with SqlClient 5.1.5 or earlier.

The sample is attached to the issue.
MS_SMO_BackupBug.zip

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从附加的 MS_SMO_BackupBug.zip 和链接的 SMO backup sample 开始,重点关注 Backup.PercentComplete 处理程序和 Backup.SqlBackup() 调用。将行为与 Microsoft.Data.SqlClient 5.1.5 和 5.2.0 进行比较,然后验证在处理程序保持启用的情况下,sample 在 5.2.0 上能够完成且不会出现 NullReferenceException。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, sql
领域
databases
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。