New Posts New Posts RSS Feed: How to use Ideablade server side?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

How to use Ideablade server side?

 Post Reply Post Reply
Author
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Topic: How to use Ideablade server side?
    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
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post 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. 


Edited by mgood - 12-Nov-2012 at 9:23am
Back to Top
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Posted: 13-Nov-2012 at 1:14am
So you suggest me to not use Cocktail/Caliburn Micro but a canonical MEF?
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 13-Nov-2012 at 8:17am
Well, what you use is up to you as long as it's not Cocktail/Caliburn.Micro.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down