[英]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.