Click here to Skip to main content
12,698,476 members (23,356 online)
Click here to Skip to main content
Add your own
alternative version


4 bookmarked

WCF and Windows Services: Object Initialization of WCF Client Proxy Takes Too Much Time

, 7 Jul 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
How to avoid delay in Object Initialization of WCF client proxy in a Window service


Today, every application is expected to be run on its own without the help of users, and window services provide a solution to that problem. Also in distributed environment, WCF provides an almost perfect solution for network calls and data transfer. When both are used together, it provides benefits in many cases.

But when in Window Service, WCF Client object is initialized, it may happen that it takes times to be initialized (usually it takes 15-20 second). Developer may think that network is causing the delay. But the actual problem lies with the Windows 7 user rights. When we initialize the object, it actually establishes a collection over the network to secure a communication passage, but it requires authentication. WCF provides its own level of authentication and user can change its setting via CONFIG file, but it does not serve the purpose in all cases. Windows Service is one such case when an extra level of authentication is performed by the application.

Problem: Object Initialization takes too much time by WCF object initialization in a Windows service application.

Assumption: Developer has basic knowledge of WCF client Proxy and Window Services.

Using the Code

Suppose I have Contract ConCat and I have added its proxy reference to a project which is being used inside a Window Service project.

ContractConcat.ConcatClient obj = new ContractConcat.ConcatClient();

App.Config contains:

         <endpoint address="" binding="wsHttpBinding"
             bindingConfiguration="WSHttpBinding_IConcat" contract="ContractConcat.IConcat"
                 <userPrincipalName value="AnantBeriwal-PC\Anant Beriwal" />

User may experience a wait of several seconds in this single point of statement. The call to initialize object of WCF client will wait until window does not authenticate it. However, this can be skipped. User only has to provide proper rights to Windows Service.


The problem lies with the privileges that are being set by OS on the Windows services. WCF has its own authentication but windows service requires separate authentication if a network connection is established.

Providing User Rights

  1. Go to Run window.
  2. Type Service.msc, press OK.
  3. Select your service, right click on it, select Properties.
  4. On second tab, "Log On", select option this account.
  5. Type your current user (or admin user) credentials, then click apply.

Window Service Properties

That's all folks. Have a good day.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Anant Beriwal
Engineer adobe
India India
Software developer and product designer, writer (both technical and non-technical)
Researcher at heart, engineer by mind Smile | :)

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 8 Jul 2014
Article Copyright 2014 by Anant Beriwal
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid