Print Page | Close Window

How to use Ideablade server side?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3790
Printed Date: 13-Apr-2026 at 7:15pm


Topic: How to use Ideablade server side?
Posted By: pponzano
Subject: How to use Ideablade server side?
Date Posted: 12-Nov-2012 at 5:46am
Hello,
I've a silverlight5 application, I'm using Telerik Reporting for generating reports, Telerik Reporting uses CaliburnMicro/Cocktail to retrieve data (using an IApplicationRepository) . When I generate a file from the WebServer (in a WCF service) I got the exception that the thread used is not the one what's been istantiated before, I've fixed for now using

  public IEnumerable<IF_SP_TMR_SNAPSHOT_INDICATORE_SELECT_Result> GetSnapshotFromGaugeAvg(int idGauge, DateTime startDate, DateTime endDate,int stepping)
        {
            tmrEntityManager.Manager.AuthorizedThreadId = null; //<----THIS
            var query = tmrEntityManager.Manager.IF_SP_TMR_SNAPSHOT_INDICATORE_SELECT_AVGQuery(idGauge, startDate, endDate,stepping);

            var op = query.Execute();

            return op.Cast<IF_SP_TMR_SNAPSHOT_INDICATORE_SELECT_Result>().AsEnumerable();
        }

How can I fix it in order to avoid this workaroud? Consider I need to wait before transferring the report back to SL so I can't use the ExecuteAsync

Thanks



Replies:
Posted By: mgood
Date Posted: 12-Nov-2012 at 9:08am
You need to ensure that you create a new EntityManager in each WCF request. What is tmrEntityManager and where does it get created? You get this exception, because you are obviously using an EntityManager from a previous request. You can't share an EntityManager between multiple requests. Each WCF request is handled by its own thread.

Are you trying to use Cocktail on the server by any chance? If so, that's not going to work. For one thing it uses a single gobal MEF container. That's fine on a client, but that's not going to work on the server. Each WCF request should use it's own container, otherwise if you have shared parts in your container, for example an EntityManagerProvider, you end up in exactly this situation where you inadvertently share instances across WCF requests and you end up in a threading nightmare. 


Posted By: pponzano
Date Posted: 13-Nov-2012 at 1:14am
So you suggest me to not use Cocktail/Caliburn Micro but a canonical MEF?


Posted By: mgood
Date Posted: 13-Nov-2012 at 8:17am
Well, what you use is up to you as long as it's not Cocktail/Caliburn.Micro.



Print Page | Close Window