How to use the WcfClientBase helper class for WCF connections?

≡放荡痞女 提交于 2019-12-24 07:43:44

问题


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:


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



来源:https://stackoverflow.com/questions/11435245/how-to-use-the-wcfclientbase-helper-class-for-wcf-connections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!