1

我有一个 WCF 服务,IMyService。在此服务中,有一个使用 System.IProgress 的操作。

public async Task MyOperation(int id, IProgress<long> progress)

我使用 Autofac 为 IMyService 服务创建客户端

builder.Register(c => c.Resolve<ChannelFactory<IMyService>>().CreateChannelWithIssuedToken(xmlToken)).As<IMyService>()

现在,我收到此错误:

[NotSupportedException: The use of 'System.IProgress`1[System.Int32]' on the task-based asynchronous method is not supported.]          
 System.ServiceModel.Description.TaskOperationDescriptionValidator.EnsureParametersAreSupported(MethodInfo method) +5776097
 System.ServiceModel.Description.TaskOperationDescriptionValidator.Validate(OperationDescription operationDescription, Boolean isForService) +16119179
System.ServiceModel.Description.ServiceEndpoint.Validate(Boolean runOperationValidators, Boolean isForService) +546
System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose) +74
System.ServiceModel.ChannelFactory.OnOpening() +30
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
System.ServiceModel.ChannelFactory.EnsureOpened() +119
System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via) +161
System.ServiceModel.ChannelFactory`1.CreateChannelWithIssuedToken(SecurityToken issuedToken) +39
TSANDC.Mdb.UI.Web.<>c__DisplayClass10.<RegisterServiceEndpoint>b__f(IComponentContext c) in c:\Projects\MyProject\App_Start\AutofacConfig.cs:148
Autofac.Builder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) +15
    Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +32
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +86
Autofac.Core.Resolving.InstanceLookup.Execute() +62
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +170
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +124
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +272
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +86
Autofac.Core.Resolving.InstanceLookup.Execute() +62
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +170
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +50

错误是关于基于任务的异步模式不支持 IProgress。这似乎不对,请有人帮忙。

4

0 回答 0