簡體   English   中英

我在兩個不同的應用程序中具有相同的代碼,但在一個應用程序中,我的 OperationContextScope 被亂序處理

[英]I have the same code in two different applications but in one I have this OperationContextScope being disposed out of order

在閱讀了文檔和論壇之后,我發現問題是因為我在OperationContextScope中使用了 await 而產生的。 我正在使用 ASP.NET Core 6 MVC 和 C#。

問題是代碼在兩個不同的應用程序中復制,實際上它們具有相同的代碼,但在一個我有OperationContextScope錯誤,而在另一個沒有。

using (new OperationContextScope(client.InnerChannel))
{                       
    SoapAuthenticationHeader.Create(client.ClientCredentials.UserName.UserName, 
    client.ClientCredentials.UserName.Password);

    zWsGetList = CreateZWSGetListObject(param);

    var GetListResponse1 = await client.GetListAsync(zWGetList);

    // Rest of the code
}

我使用了斷點,但它在退出斷點后中斷。

抱歉,如果我在可能是新手的事情上錯了,但對我來說似乎很奇怪,在一個應用程序中它可以完美運行,而在另一個應用程序中卻沒有,而且它們都完全相同。 也許是一個nuget包?

我安裝了這個 NuGet,它終於奏效了:

System.ComponentModel.Annotations
System.Configuration.ConfigurationManager
System.ServiceModel.Duplex
System.ServiceModel.Federation
System.ServiceModel.Http
System.ServiceModel.NetTcp
System.ServiceModel.Security

其中一些是默認安裝的,其他的我必須手動安裝。 希望你覺得這很有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM