Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

WCF and Windows Authentication


I am hosting a WCF service within an application that uses windows authentication to identify and authenticate its users. Now I am trying to consume these WCF services on my android client which requires that my android application authenticates itself using windows authentication before it could access the service, I am trying the following code, but unfortunately it throws and exception.

        EmployeeServicesWCFClient empServices = new EmployeeServicesWCFClient();
            BasicHttpBinding binding = new BasicHttpBinding();
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;

            EndpointAddress endpoint = new EndpointAddress("");

            empServices = new EmployeeServicesWCFClient(binding, endpoint);
            empServices.ClientCredentials.UserName.UserName = "\\Mostafa";
            empServices.ClientCredentials.UserName.Password = "password";

    Employee emp = empServices.GetEmployeeInfo();

when the above code is executed, the line below in the WCF generated proxy class throws a null reference exception

            public CSEDataContracts.Employee GetEmployeeInfo()
                    return base.Channel.GetEmployeeInfo();

P.S. I have windows authentication enabled and anonymous authentication disabled for the website configuration in the IIS.

any idea what is the problem?


  • kocak_bariskocak_baris BEMember

    No explanation no source for this issue.. There is no config file in the project WTF..
    Im searching for 2 days how to solve this problem but in every forum there is question but no response..
    im sick of this..

  • MostafaElAwadyMostafaElAwady EGMember ✭✭

    I have worked around it by send the username and password with each method call, then using impersonation on the server side hosting the service to manually do the authentication locally.

    FYI, xamarin support answer was that their framework doesn't support the WCF Windows authentication combo.

    Good luck

Sign In or Register to comment.