How to use the WcfClientBase helper class for WCF

2019-08-05 04:01发布

Ufuk Hacıoğulları wrote a nice WCF helper class called WcfClientBase. However I've had some difficulty in implementing it.

I defined my class as follows:

public class ModelsBaseClass : ServiceClientBase<MemberServiceClient>
{...

And attempting to use the helper class in the following method that returns a complex object through Entity Framework:

    public static MyProject.DAL.Primary.Models.sq_newsfeed_GetProfileByID_Result GetAllProfileDetails(int profileID)
    {
        try
        {
            using (memberServiceClient = new MemberServiceClient())                                // connect to the data service
            {
                return memberServiceClient.GetAllProfileDetailsByID(profileID);
            }
        }
        catch (Exception ex)
        {
            ErrorLogging.Instance.Fatal(ex);
            return null;
        }
    }

Following the examples here, I am unable to access the class' methods even though this is a derived class, and the protected access modifier should allow access - right?

Basically I cannot access the PerformServiceOperation or TryPerformServiceOperation methods in my model base class.

1条回答
神经病院院长
2楼-- · 2019-08-05 05:06

Did you notice your method is static? That's the reason you cannot access instance members of the parent class.

查看更多
登录 后发表回答