hi all
i have a requirement..
1. i have lot of BL objects hosted in IIS single call mode,
2. depends on the parameter given to the methods, or some time if there is
no parameter also.. we will go and read an xml file which is present in
RemotingServer directory (IIS dir) for some information let us say.. it is a
connection string..
based on this connectionstring and parameters further dll calls will be made..
3. sometimes SQL,Oracle, OLEDB, ODBC ..etc.. depends on the type we would
instanciate particular DAL dll thru. activator.createinstance..
4. Can i avoid reading xml file at the server.. and access from the another
remoting object... (singleton)...
5. to be more specific..
i have BL CustomerBL.rem...with lot of methods.. Check(1) method...
in check(1) if it is "1" create, instantiate .. that DLL1
if it is "2" create, instantitate that DLL2
6. I am maintaining this in XML file.
7. shall i call another GetConnBL.rem from CusotmerBL.rem to get the
subsequent connection string..? instead doing an I/O operation READING AN XML
FILE..
if you need more details please reply me
regs
sahridhayan
Beth Massi [Architect MVP] - 11 May 2005 01:50 GMT
You can definately use an object on your server to load the xml file
settings into memory instead of accessing the file on disk everytime a
setting is needed. If your publicly exposed objects are all single-call what
I would do is create a class that loads the xml file settings into the
server's memory (like a dictionary) and then create a shared (static)
reference to it. If you create the reference in a static constructor of your
remoted objects' base class then this would get created the first time the
client requested *any* remote object. This design also takes care of
re-creating the settings object when the lease expires or the server
application is restarted and the object is garbage collected. Something
like:
Public MustInherit Class MyBusinessBase '-- Remoted single-call object
Inherits MarshalByRefObject
Private Shared m_settings As MyConfigSettings
Protected ReadOnly Property Settings() As MyConfigSettings
Get
Return m_settings
End Get
End Property
Shared Sub New()
m_settings = New MyConfigSettings()
End Sub
.
.
.
. '-- rest of class def
End Class
HTH,
-Beth
> hi all
>
[quoted text clipped - 32 lines]
> regs
> sahridhayan
sahridhayan - 14 May 2005 12:33 GMT
Thanks Beth.. It was very useful.. it is efficient in using memory ..
One more approach i am thinking.. since all the calls in IIS (remoting
object hosted )
why dont we use the "HttpContext.Current.Application["Schema Owner"]" (sample)
to fetch the data..
will it hold data in IIS memory automatically after retreiving from the
web.config...?
may be after first call... for accesing this value
what do you all think about this?
Regs
Sahridhayan
> You can definately use an object on your server to load the xml file
> settings into memory instead of accessing the file on disk everytime a
[quoted text clipped - 67 lines]
> > regs
> > sahridhayan
Beth Massi [Architect MVP] - 14 May 2005 17:07 GMT
Interesting. I suppose that would work but the solution I gave you will work
without IIS and the Settings object can be anything you want it to be so it
seems more flexible in this case. I have to avoid using HttpContext in our
products because the components can be deployed in a variety of physical
configurations and can't rely being in IIS.
-B
> Thanks Beth.. It was very useful.. it is efficient in using memory ..
>
[quoted text clipped - 91 lines]
>> > regs
>> > sahridhayan
sahridhayan - 16 May 2005 13:33 GMT
It is not working i am able access HttpRunTime....
But accessing HttpContext.Current.Application["Schema Owner"] like this
not giving any values....(null)
some of my findings..(command window access i/p vs o/p
------------------------------------------------------------------------------------------
?System.Web.HttpContext.Current.Application["Product DatabaseType"]
function 'System.Web.HttpContext.Current.Application.get_Item' evaluated and
returned nul
------------------------------------------------------------------------------------------
?HttpContext.Current.GetConfig("Product DatabaseType")
function 'HttpContext.Current.GetConfig' evaluated and returned nul
------------------------------------------------------------------------------------------
?HttpContext.GetAppConfig("Product DatabaseType")
function 'HttpContext.GetAppConfig' evaluated and returned null
------------------------------------------------------------------------------------------
?HttpContext.Current.Application[0]
{"Index was out of range. Must be non-negative and less than the size of
the collection.\r\nParameter name: index" }....
any insight into thesee approach..
thanks
sahridhayan
> Interesting. I suppose that would work but the solution I gave you will work
> without IIS and the Settings object can be anything you want it to be so it
[quoted text clipped - 99 lines]
> >> > regs
> >> > sahridhayan