WebDAV 和Exchange 2003 - 在调试中工作,失败时没有

发布于 2024-09-24 09:08:35 字数 2392 浏览 5 评论 0原文

所以我有一个非常奇怪的问题。

我正在 .NET 2.0 下的 VB.Net 中编写一些代码,该代码与 MS Exchange 2003 交互。由于 Exchange 2003“要求”,我被迫使用 WEBDAV 编写此代码。

代码本身在某种程度上复制了日程管理过程。它在 Exchange Server 上创建约会以响应用户的输入,并在 SQL Server 数据库内部管理其数据。 问题情况是这样的:一个会议被指派了一个新人来负责。该要求表示,程序应向从会议中删除的人员(如果存在这样的人员)生成会议取消请求,并向新人员发送会议请求。

在已有人员的情况下,似乎会发生以下情况:

  1. 会议取消请求 发送
  2. 在设置期间 Exchange barfs 并返回状态代码 500(内部服务器错误) requests 将会议请求发送给新人员。

然而!在调试这个特定场景时,如果我在 Visual Studio 调试器中单步调试代码,它对我来说效果很好。留给它自己的设备,它每次都会失败。

只是为了 yuk 的缘故,我在发送取消请求后添加了一个 Thread.Sleep(500) 到该部分,并且 Exchange 不再呕吐......

所以,我的问题!

如果在代码中添加 Thread.Sleep 会导致此错误消失,则暗示存在竞争条件,不是吗?但是,我的代码在 Web 应用程序下运行,并且从开始到结束都是一个完全单线程的进程。我发送的网络请求都是同步模式,所以这应该不是问题。

接下来我要做什么来尝试追踪问题?

  • 尝试猜测竞争条件本身是否在 .Net 2.0 BCL 网络代码中?
  • 尝试在 Exchange 服务器本身上进行一些调试?
  • 忽略它,很高兴 Thread.Sleep 掩盖了问题并继续下去?

任何进一步的建议都会很棒。


作为对评论的回应,我可以发布失败的函数:

    Private Shared Sub UpdateMeeting(ByVal folder As String, ByVal meetingId As String, ByVal oldAssignedId As String, ByVal newAssignedTo As String, ByVal transaction As DbTransaction)
        If String.IsNullOrEmpty(meetingId) Then
            Throw New Exception("Outlook ID for that date and time is empty.")
        End If
        Dim x As New Collections.Generic.List(Of String)
        If oldAssignedId <> newAssignedTo AndAlso Not String.IsNullOrEmpty(oldAssignedId) Then
            'send cancellation to old person
            Dim lGetCounselorEmail1 As String = GetCounselorEmail(oldAssignedId, transaction)
            Common.Exchange.SendCancellation(meetingId, New String() {lGetCounselorEmail1})
            ' Something very weird here. Running this code through the debugger works fine. Running without causes exchange to return 500 - Internal Server Error.
            Threading.Thread.Sleep(500)
        End If
        x.Add(folder)
        If Not String.IsNullOrEmpty(newAssignedTo) Then x.Add(GetCounselorEmail(newAssignedTo, transaction))
        x.RemoveAll(AddressOf String.IsNullOrEmpty)
        If x.Count > 0 Then
            If Not Common.Exchange.UpdateMeetingAttendees(meetingId, x.ToArray()) Then
                Throw New Exception("Failure during update of calendar")
            End If
        End If
    End Sub

...但是这里隐藏了很多实现细节,因为我编写了一组与 Exchange WebDAV 交互的类。

So I have a very weird problem.

I am writing some code in VB.Net under .NET 2.0 which interfaces with MS Exchange 2003. Because of the Exchange 2003 "requirement" I am forced to write this code using WEBDAV.

The code itself is replicating, to some degree, a schedule management process. It's creating Appointments on the Exchange Server in response to inputs from the user and managing it's data internally in a SQL Server database.
The problem situation is this: A new person is assigned to be in charge of a meeting. The requirement says the program should generate a meeting cancellation request to the person removed from the meeting (if such a person existed) and a meeting request sent to the new person.

In the case of there being an existing person, what appears to happen is this:

  1. The meeting cancellation request
    gets sent
  2. Exchange barfs and returns status code 500 (internal server error) during the set of
    requests which send the meeting request to the new person.

However! While debugging this particular scenario, it works just fine for me, if I step through the code in the Visual Studio debugger. Left to it's own devices, it fails every time.

Just for yuk's sake, I added a Thread.Sleep(500) to the part after sending the cancellation request, and Exchange doesn't barf anymore...

So, my question!

If adding a Thread.Sleep to the code causes this error to go away, a race condition is implied, no? But, my code is running under a web application and is a totally single threaded process, from start to finish. The web requests I am sending are all in synchronous mode so this shouldn't be a problem.

What would I do next to try and track down the issue?

  • Try and divine if the race condition itself is in the .Net 2.0 BCL networking code?
  • Try and do some debugging on the Exchange server itself?
  • Ignore it, be glad the Thread.Sleep masks the problem and keep on going?

Any further suggestions would be wonderful.


In response to comment, I can post the failing function:

    Private Shared Sub UpdateMeeting(ByVal folder As String, ByVal meetingId As String, ByVal oldAssignedId As String, ByVal newAssignedTo As String, ByVal transaction As DbTransaction)
        If String.IsNullOrEmpty(meetingId) Then
            Throw New Exception("Outlook ID for that date and time is empty.")
        End If
        Dim x As New Collections.Generic.List(Of String)
        If oldAssignedId <> newAssignedTo AndAlso Not String.IsNullOrEmpty(oldAssignedId) Then
            'send cancellation to old person
            Dim lGetCounselorEmail1 As String = GetCounselorEmail(oldAssignedId, transaction)
            Common.Exchange.SendCancellation(meetingId, New String() {lGetCounselorEmail1})
            ' Something very weird here. Running this code through the debugger works fine. Running without causes exchange to return 500 - Internal Server Error.
            Threading.Thread.Sleep(500)
        End If
        x.Add(folder)
        If Not String.IsNullOrEmpty(newAssignedTo) Then x.Add(GetCounselorEmail(newAssignedTo, transaction))
        x.RemoveAll(AddressOf String.IsNullOrEmpty)
        If x.Count > 0 Then
            If Not Common.Exchange.UpdateMeetingAttendees(meetingId, x.ToArray()) Then
                Throw New Exception("Failure during update of calendar")
            End If
        End If
    End Sub

...but a lot of the implementation details are hidden here, as I wrote a set of classes to interface with Exchange WebDAV.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

油饼 2024-10-01 09:08:35

最终坚持睡眠并结束了一天。

我的“信念”是,我错误地认为通过 WebDav 发送到 Exchange 的 WebRequest/WebResponse 组合是原子操作。

Ended up sticking with the Sleep and calling it a day.

My 'belief' is that I was erroneous in thinking that a WebRequest/WebResponse combo sent to Exchange through WebDav was an atomic operation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文