Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have created a self hosted wcf service in a win form app. Every thing works fine(the communication)...
Problem: My application starts on system startup, and as soon as my app starts it triggers my wcf service to start "selfHost.Open()"
but the main problem is it hangs up the system. making the application not usable for aroung 20 30 seconds.
Do any of you have a solution.
Thanks in advance
Nitin Verma
Posted

Use all communication part in a separate thread. Don't even play with the idea of doing networking, remoting or WCF without threading.

—SA
 
Share this answer
 
Comments
Sandeep Mewara 24-May-11 4:22am    
Comment from OP:
Thanks SA,
I have started the wcf service in saperate thread, but still it hangs the system,
I guess the problem is somewhat related to the system startup, Because it does not hang when I logoff and login the XP.
But the problem only occurs when I restart the system.
Nitin
Sergey Alexandrovich Kryukov 24-May-11 22:05pm    
If can happen, too. It's just there is no enough information to dig into your problem.
--SA
Thanks SA,
I have started the wcf service in saperate thread, but still it hangs the system,
I guess the problem is somewhat related to the system startup, Because it does not hang when I logoff and login the XP.
But the problem only occurs when I restart the system.
Nitin
 
Share this answer
 
Comments
Wannes Geysen 24-May-11 4:00am    
The problem is probably that your network connection isn't ready when you want to connect to your wcf service. Try using a short delay, or try to see if your network connection is set up before you try to connect to your WCF service
Nitin_Verma 25-May-11 2:58am    
but my nerwotk connection is ready at the moment when m trying to start the wcf service
Nitin Verma
Wannes Geysen 25-May-11 3:14am    
check the following links:
http://blogs.msdn.com/b/andreal/archive/2008/07/19/wcf-service-startup-too-slow-have-you-thought-to-crl-check.aspx

http://www.codeproject.com/Tips/114132/WCF-First-Call-Slow.aspx
Nitin_Verma 25-May-11 9:52am    
Thanks Wannes,
I gone through those articles.
I applied the above said setting in my app.config file but no effects in starting time of my app.


Actually mine is a self hosted wcf service in a win form App. And I am running this application on windows startup. and it takes aroung 50-60 seconds to load the application.

Nitin :(
Wannes Geysen 27-May-11 11:00am    
and if you try to run another application on the startup of your system, does it also takes as much time. Because in that case, maybe you are starting too much applications at the same time and is that the reason why your system is running slow.
Thanks again,

but le me be clear that I am not connecting to a wcf service. I am trying to start a one.

And I tried that Before trying to start it network connection has acquired IP. I have written below code to start the service.

VB
 Dim baseAddress As Uri = New Uri("http://localhost:8080/me/myService")

 Dim selfHost As New ServiceHost(GetType(WCFService), baseAddress)
 
 selfHost.AddServiceEndpoint(GetType(MyContract.IServerManager), New WSHttpBinding(SecurityMode.None), "WCFService")

 Dim smb As New ServiceMetadataBehavior()
            smb.HttpGetEnabled = True
            selfHost.Description.Behaviors.Add(smb)
selfHost.Open()
 
Share this answer
 
Comments
Sandeep Mewara 25-May-11 0:52am    
Once again you post a comment or update of your question as an answer.
I guess you use some services that you wcf service begin

I don't know the wcf service use what can stop it,someone have the same issue

http://stackoverflow.com/questions/1234188/windows-service-hung-on-starting-during-boot


They use DependOnService attribute to add dependency

It works for me
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900