0
votes

As in the title, I've created .netcore app(v3.1) and I'm trying to debug the error when calling the wcf using net.tcp port.

I have added references to System.ServiceModel

The error occurs in ChannelFactory:

factory = new ChannelFactory<T>(binding, ea);

Error: An error occurred while loading attribute 'OperationContractAttribute' on method 'GetList' in type 'IService'. Please see InnerException for more details.

Inner exception: "Could not load type 'System.ServiceModel.Web.WebGetAttribute' from assembly 'System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.":"System.ServiceModel.Web.WebGetAttribute"

Edit Stacktrace:

"   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 ...."
1

1 Answers

0
votes

This error specifically talks about the assembly. Add the reference to System.ServiceModel.Web, this should solve the issue.