【发布时间】:2020-08-14 18:11:54
【问题描述】:
如标题所示,我创建了 .netcore app(v3.1),并尝试在使用 net.tcp 端口调用 wcf 时调试错误。
我添加了对 System.ServiceModel 的引用
ChannelFactory出现错误:
factory = new ChannelFactory<T>(binding, ea);
错误: 在“IService”类型的方法“GetList”上加载属性“OperationContractAttribute”时出错。有关详细信息,请参阅 InnerException。
内部异常:“无法从程序集 'System.ServiceModel.Web,版本 = 4.0.0.0,文化 = 中性,PublicKeyToken = 31bf3856ad364e35' 加载类型 'System.ServiceModel.Web.WebGetAttribute'。”:“System.ServiceModel .Web.WebGetAttribute"
编辑 堆栈跟踪:
" at System.ServiceModel.Description.ServiceReflector.GetCustomAttributes(ICustomAttributeProvider attrProvider, Type attrType, Boolean inherit)\r\n at System.ServiceModel.Description.ServiceReflector.GetCustomAttributes(ICustomAttributeProvider attrProvider, Type attrType)\r\n at System.ServiceModel.Description.ServiceReflector.GetSingleAttribute[T](ICustomAttributeProvider attrProvider)\r\n at System.ServiceModel.Description.TypeLoader.CreateOperationDescription(ContractDescription contractDescription, MethodInfo methodInfo, MessageDirection direction, ContractReflectionInfo reflectionInfo, ContractDescription declaringContract)\r\n at System.ServiceModel.Description.TypeLoader.CreateOperationDescriptions(ContractDescription contractDescription, ContractReflectionInfo reflectionInfo, Type contractToGetMethodsFrom, ContractDescription declaringContract, MessageDirection direction)\r\n at System.ServiceModel.Description.TypeLoader.CreateContractDescription(ServiceContractAttribute contractAttr, Type contractType, Type serviceType, ContractReflectionInfo& reflectionInfo, Object serviceImplementation)\r\n at System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(Type contractType, Type serviceType, Object serviceImplementation)\r\n at System.ServiceModel.Description.TypeLoader.LoadContractDescription(Type contractType)\r\n at System.ServiceModel.ChannelFactory`1.CreateDescription()\r\n at System.ServiceModel.ChannelFactory.InitializeEndpoint(Binding binding, EndpointAddress address)\r\n at System.ServiceModel.ChannelFactory`1..ctor(Binding binding, EndpointAddress remoteAddress)\r\n at ...."
【问题讨论】:
标签: .net visual-studio wcf asp.net-core