0

It's possible to get instance of app.config created service host? I have class A with two instances, every instance have different params, I need to host those two instances as Service Host each on different web address.

Source code:

public void RegisterService(object serviceInstance, params object[] args)
    {
        ServiceHost service = new ServiceHost(serviceInstance);
        service.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
        service.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new Common.AuthenticationValidator();

        if (serviceInstance is A)
        {
            if(args.Length > 0 && args[0] is ServiceId)
            {
                if((ServiceId)args[0] == ServiceId.Foo)
                {
                    WSHttpBinding binding = new WSHttpBinding();

                    service.AddServiceEndpoint(typeof(A), binding, "http://localhost/Foo");
                }
                else if((ServiceId)args[0] == ServiceId.Bar)
                {
                    WSHttpBinding binding = new WSHttpBinding();

                    service.AddServiceEndpoint(typeof(A), binding, "http://localhost/Bar");
                }
            }
        }

        service.Open();

        services.Add(service);
    }

If I register it via RegisterService I get error 400. Is there something I missing?

user1085907
  • 1,009
  • 2
  • 16
  • 40

0 Answers0