WCF - Return and continue processing - wcf

I have a WCF method.
I would like to return to user a result and continue processing in the server side (via .net Task).
The problem is that I have the "Cannot access a disposed object." error message when I continue processing in the server side.
can anyone help ? how can I implement that. Return a result to user but continue working in the server side.
thanks
Hagai

explore callback contract option for your scenario - http://www.dotnetcurry.com/ShowArticle.aspx?ID=721

Related

How to log error 500 in wcf applications

We all are know some time we will get 500 error while trying to hit wcf url. for example if pass string value to integer parameter it will throw 500 error as request error. my question is how to log, this kind error in some file? because this will not reach our actual end point class coding right? so how to log this error in some file?
Any Help?
Assuming you want to log these on the server size, you should configure WCF tracing and use SvcTraceViewer to analyze the logs. More details on MSDN: http://msdn.microsoft.com/en-us/library/ms732023.aspx.
I may very well be wrong here - but if the client is supplying the wrong parameters to a web method, that would be a 404 as no method matches the incoming request?
I would say it's the clients job to send the right data to the right function, and to handle failures appropriately (an EndPointNotFoundException perhaps)

WP7 and WCF Services: Fast app switching

I'm currently building a WP7 app that consumes WCF Data Services hosted on a web server. What I'd like to deal with is
cathayService.ServiceException += (sender, e) =>
{
Debug.WriteLine(e.Exception.ToString());
MessageBox.Show(e.Exception.ToString(), "Service Error", MessageBoxButton.OK);
};
The service exception triggers if I have a lack of internet connectivity. It also triggers when I face with fast app switching. How'd I be able to differentiate the source of the ServiceException?
Hope someone can give me an idea... Many thanks! :)
[It's unclear if you are getting a ServiceException instance, or if you are referring to the ServiceException event in some places above]
Check the exception you get - if it's typed as ThreadAbortException, that means you are being switched out. If you actually get a ServiceException thrown, check it's inner Exception and see if THAT guy is ThreadAbortException.
My suggestion is that you don't hook that event though and instead use the actual callback events on the WCF client to check the .Error property of the EventArgs you get back.

Function evaluation timed out

I am using linq to sql in a Silverlight application and I keep getting this debug error..
http://www.freeimagehosting.net/uploads/bf4055b4ee.jpg
This code runs when the application is started up without problems. When I call it the second time, I only get a few of the results. When I add a breakpoint to the WCF service I get the following error...
Could someone please tell me whats going on here so i can make some changes?
TIA
ps. Might not be the most efficient coding but I will sort all that out later :P
If you add a breakpoint to the service code the caller will throw a Timeout Exception after the timeout time has passed. Raise the timeout of your service (on the server and client side), this will allow you to debug your service code without getting exceptions.

Using WCF client

In my application, I am using client.open and client.close to open a WCF proxy channel, use the wcf method and finally close it. I do this is several parts of my Windows Forms application.
However, I have noticed that client.close does not necessarily close the connection immediately. Why is this? Should I use client.Abort instead?
Am I using the WCF client the right way? i.e. clien.open -> call WCF method -> client.close.
Thanks for any help in advance!
Subbu
The .Close() method will try to close the connection gracefully, e.g. a pending call will still be finished by the server, and only after that's done, the connection is terminated. Use this whenever possible - it's the gentle and preferred way of closing a client connection.
.Abort() really just tears down the communication channel - not matter whether a call is still in progress or not. It's the ultimate, last resort escape hatch, if .Close() failed.
As a best practice, I would wrap my service calls into a try...catch block, something like this:
try
{
myServiceClient.CallSomeMethod();
myServiceClient.Close();
}
catch(FaultException<SomeError>)
{
myServiceClient.Abort();
}
// possibly other catch clauses, too - call .Abort() inside them
catch(CommunicationException)
{
myServiceClient.Abort();
}

Data not coming through from RIA Services in Silverlight

I had a connection working but something changed and now the data isn't showing up. It is a simple query that worked before that just returns all entities. I put in break points on the LoadOperation call and it fires and gets 0 entities. I also put a break point on the service itself, and it does not break before the LoadOperation evaluates. After the LoadOperation completes, then the service query is called... well after we needed the data. The only thing that I can think of that could be a problem is that I added 2 WCF services to the solution. Would WCF services stop the RIA from working? Any ideas on what else could cause the problem?
Client:
LoadOperation<Project> loadOp =
this._projectContext.Load(this._projectContext.GetProjectsQuery());
Service:
public IQueryable<Project> GetProjects()
{
return this.Context.Projects;
}
See, real basic, but not working.
You need to put a callback method on your Load operation and then check the results of the LoadOperation.Error when it comes back. In that error you will find the exception which will let you know what the problem is (you will probably have to check the inner exception to get the full details).