tags:

views:

48

answers:

2
  1. I have a WCF app on NetTCP Binding based. In client app i have created its proxy class object as static. This client app may run for 4-8 hrs after deployment. Basically at login window I am creating and initializing DataServiceClient proxy class (mainly database insert & updates) and using same object throughout my application until user closes Main Window. Is there any adverse effect (performance wise) of creating static object of proxy class? If yes then how I can avoid this. Before using static object I was creating individual object at every window (wherever required) but this had increased window loading time.

  2. How I can improve WCF performance. I am satisfied with its performance but it could be my illusion.

+1  A: 

Looks like you client is a Windows Forms application - a static service proxy should be ok for you as long as you don't do any multi-threading or callbacks on your proxy etc. Essentially, in such case, you need to synchronize the access to static variables.

Talking in general terms, WCF performance can be improved

  1. Designing the service contract carefully - its should be chunky interface and not chatty so that number of service calls gets reduced
  2. Choosing appropriate binding - TCP Binding would be faster than HTTP Binding but it would be .NET propriety and may not work over internet as other ports would be blocked. If your communicating on same machine then named piped binding would be the fastest mode
VinayC
+2  A: 
  1. Nothing wrong with using the same instance, but make sure your error handling is good. Otherwise the proxy object will go into a faulted state when an error happens and you have to restart the whole application. There are some events you can attach to when the state changes. After the proxy object goes into the faulted state you have to create a new one, there is no way to recover a faulted proxy object.

  2. I have found that using message headers reduces the amount of methods I actually need to expose, but that really depends on what your service does. Otherwise I would recommend to use streaming when possible. Keep your data as small as possible. Use the binary formatter.

Flo
I have chosen WCF b'coz my client app need data access on server. my app is like distributed POS app. So WCF contains only database access using stored proc.
RAJ K
Sounds pretty straight forward to me and I would not expect any problems. Using a static proxy object will improve your performance because you don't have to create a new channel for every call, but I am not sure if you will actually notice it.
Flo