views:

182

answers:

2

I have a component (an assembly built in .net) that i need to access on (almost) every request to two different websites. One website is written in classic asp and the other one in asp.net mvc.

At the moment i reference the assembly in the asp.net solution and call it like i would any .net assembly. On the classic asp website, i call it through a COM wrapper.

This is all good, except now i need this component to actually stay alive and monitor changes to a configuration file. In my asp.net website i could keep a refence in the application scope and i guess i could register it in component services for the asp access.

Is this the best way to do it? Also, this way the component would actually be hosted twice - one instance in the asp.net application scope and one in the component services. I could perhaps instead only have it live in component services, and then instead reference it from asp.net.

I don't know - something smells fishy (and no, it's not me) - am i on the right track or do you see better alternatives?

A: 

Do you really need a long running object? You say you need to monitor configuration file changes -- when the config changes do you need to trigger some actions or do you just need to ensure that each incoming request uses the latest copy of the configuration for your component? If it is the latter then standard .NET configuration should work for you without concern for the object lifetime.

In terms of hosting, do you need to use any COM+ services? If not, then I would not use COM+. If you want one central location for your .NET component, why not register it in the GAC?

Tuzo
This components is going to be called for almost every request to an asp.net website and for many requests to a legacy classic asp site, hence i want the initialization (reading/parsing of a file) to happen as fast as possible. Also i need to be able to call it from VBScript (the classic asp site) which can't call .net assemblies directly.
Per Hornshøj-Schierbeck
A: 

Ok so i think i found two solutions, both acceptable for this project:

1) Register it in global.asa on the Application_OnStart in the Application object like this Application("Someobject") = Server.CreateObject("Someobject")

2) Host it in component services and handle lifetime there.

Per Hornshøj-Schierbeck

related questions