Connecting to Remote Portal

Connecting to Remote Portal

Old forum URL: forums.lhotka.net/forums/t/528.aspx


Cslah posted on Monday, July 03, 2006

I have an interesting bug that I'm trying to fix (Csla 1.5). Our app uses a login dialog that allows the user to connect to a DB locally or type in the URL for a remote dataportal. We change the connection string in the config file to accomidate this. A user can log out and log back in to get to another dataportal.

I'll point out before I go too far that we had to modify Csla to not use a connection string from the app.config file. .Net loads the config file ONCE during startup and will not load it again until you restart your application. Thus, changing the connection string won't take effect in a login dialog where the user can dynamically specify where they want to connect. To do this we made a connection.xml file and have our app read/write to it. We made Csla read from this file as well. This solved that problem.

Now, however, I have a bug that if you typed in the wrong address you're stuck with it until you restart. Csla seems to ALWAYS use the first portal address you used.

For some reason I think this might be in the ApplicationContext object somewhere? Is there a way to 'clear out' the connection to just start from scratch without restarting the app? I tried the .Clear() method on:

CSLA.ApplicationContext.Clear()
CSLA.ApplicationContext.ClientContext.Clear()
CSLA.ApplicationContext.GlobalContext.Clear()

None of these seem to work though, and I'm still stuck with the URL that the user first typed in.

Anyhow know how I can 'reset' things without restarting?

Thanks,
Brian

RockfordLhotka replied on Tuesday, July 18, 2006

It is in the client-side DataPortal class. That class contains code to cache the first data portal server object that is created, and then it just uses the cached instance. You'll need to modify the client-side DataPortal class to not cache the object.

Copyright (c) Marimer LLC