Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:04:44+00:00 2026-06-14T22:04:44+00:00

I have wcf library with service contracts and implementations. [ServiceContract] public interface IServiceProtoType {

  • 0

I have wcf library with service contracts and implementations.

     [ServiceContract]
    public interface IServiceProtoType 
    {
        [OperationContract]
        Response GetMessage(Request request);

        [OperationContract]
        String SayHello();

    }
    [DataContract]
    public class Request
    {
        private string name;

        [DataMember]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

    }
    [DataContract]
    public class Response
    {
        private string message;

        [DataMember]
        public string Message
        {
            get { return message; }
            set { message = value; }
        }

    }
 public class MyDemoService : IServiceProtoType
    {
        public Response GetMessage(Request request)
        {
            var response = new Response();
            if (null == request)
            {
                response.Message = "Error!";
            }
            else
            {
                response.Message = "Hello, " + request.Name;
            }
            return response;
        }
        public string SayHello()
        {
            return "Hello, World!";
        }
    }

I have windows service project that references this library, where MyService is just an empty shell that inherits ServiceBase. This service is installed and running under local system.

static void Main()
        {
          ServiceBase.Run(CreateContainer().Resolve());
        }

        private static IWindsorContainer CreateContainer()
        {
            IWindsorContainer container = new WindsorContainer();
            container.Install(FromAssembly.This());
            return container;
        }

 public class  ServiceInstaller : IWindsorInstaller
    {

        #region IWindsorInstaller Members

        public void Install(IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {

            string myDir;

            if (string.IsNullOrEmpty(AppDomain.CurrentDomain.RelativeSearchPath))
            {
                myDir = AppDomain.CurrentDomain.BaseDirectory;
            }
            else
            {
                myDir = AppDomain.CurrentDomain.RelativeSearchPath;
            }

            var wcfLibPath  = Path.Combine(myDir , "WcfDemo.dll");
            string baseUrl = "http://localhost:8731/DemoService/{0}";
            AssemblyName myAssembly = AssemblyName.GetAssemblyName(wcfLibPath);

            container
                .Register(
                    AllTypes
                        .FromAssemblyNamed(myAssembly.Name)
                        .InSameNamespaceAs<WcfDemo.MyDemoService>()
                        .WithServiceDefaultInterfaces()
                        .Configure(c =>
                                   c.Named(c.Implementation.Name)
                                       .AsWcfService(
                                           new DefaultServiceModel()
                                               .AddEndpoints(WcfEndpoint
                                                                 .BoundTo(new WSHttpBinding())
                                                                 .At(string.Format(baseUrl,
                                                                     c.Implementation.Name)
                                                                 )))), Component.For<ServiceBase>().ImplementedBy<MyService>());
        }

        #endregion
    }

In Client Console app I have the following code and I am getting the following error:
{“Sequence contains no elements”}


static void Main(string[] args)
        {
            IWindsorContainer container = new WindsorContainer();
            string baseUrl = "http://localhost:8731/DemoService/{0}";
            container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero);

            container
                .Register(
                    Types
                        .FromAssemblyContaining<IServiceProtoType>()
                        .InSameNamespaceAs<IServiceProtoType>()
                        .Configure(
                            c => c.Named(c.Implementation.Name)
                                     .AsWcfClient(new DefaultClientModel
                                     {
                                         Endpoint = WcfEndpoint
                                             .BoundTo(new WSHttpBinding())
                                             .At(string.Format(baseUrl,
                                                 c.Name.Substring(1)))
                                     })));


            var service1 = container.Resolve<IServiceProtoType>();

            Console.WriteLine(service1.SayHello());

            Console.ReadLine();

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:04:45+00:00Added an answer on June 14, 2026 at 10:04 pm

    I have an idea what this may be but you can stop reading this now (and I apologize for wasting your time in advance) if the answer to the following is no:

    Is one (or more) of Request, Response, or MyDemoService in the same namespace as IServiceProtoType?

    I suspect that Windsor is getting confused about those, since you are doing…

    Types
        .FromAssemblyContaining<IServiceProtoType>()
        .InSameNamespaceAs<IServiceProtoType>()
    

    … and then configuring everything which that returns as a WCF client proxy. This means that it will be trying to create proxies for things that should not be and hence a Sequence Contains no Elements exception (not the most useful message IMHO but crushing on).

    The simple fix would be just to put your IServiceProtoType into its own namespace (I often have a namespace like XXXX.Services for my service contracts).

    If that is not acceptable to you then you need to work out another way to identify just the service contracts – take a look at the If method for example or just a good ol’ Component.For perhaps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this: MathServiceLibrary (WCF Service Library) [ServiceContract] public interface IMathService {
I have a WCF Service Library containing five service contracts. The library is hosted
I have multiple Service contracts defined in one WCF library which are hosted under
I have a WCF Service Library (implemented using NH) with one of the class
I have a wcf service library that is hosted in a windows service. I
I currently have a WCF Service Library which will be started through a Console
I am creating solution and inside I have three projects: A WCF Service Library
I have two Services called TemplateService, TemplateReportService (both defined in one WCF Service Library)
I have a Class library with WCF service added. When I click on command
I have a Visual Studios C# Class library(A5Lib) and a WCF Service project(A5Services). the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.