tags:

views:

111

answers:

3

Hi, suppose I have some asp.net and WCF web service applications, which are running perfectly in the server.

Somehow I want to create another application A, for generic usage, I want to attach a copy of A to all those asp.net or WCF applications.

But A does not have anything to do with those applications, A just collects some data, does some background monitoring stuff. Those asp.net and WCF applications do not need to know what A does.

But my question is; Even if I add A as a reference into those applications, the code in A doesn't run.

So... do you think I can specify A in some config file, so that after deployment, A can be run automatically, and do its own job, but physically, A is living together with those asp.net or WCF applications.

Thanks

+1  A: 

One of the things that you can add to the application without having to add a reference to it into the code is a Custom Trace listener, by writing something like this into the web.config or app.config:

<system.diagnostics>
  <sources>
    <source name="yourservicename" switchValue="All">
      <listeners>
        <add name="simplename" type="YourTypeHere"
             initializeData="config values here"/>
      </listeners>
    </source>
  </sources>
</system.diagnostics>

Maybe this will do the trick for you.

jmservera
wow...cool stuff...i will try to see how it goes and come back and update to you........fantastic....
shrimpy
Hi, i try to do what u say..but it doesn`t work..i create a empty asp.net application..and create a class librarybut it didn`t work for me
shrimpy
@jmservera: How does that help?
John Saunders
A: 

Below are to library i create.... but it didn`t work for me....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ServiceHosting.ServiceRuntime;
using System.Threading;

namespace Plugin1
{
    public class Class1
    {
        static void Main(string[] args)
        {
            if (args != null)
            {
                RoleManager.WriteToLog("Information", args.ToString());
                Console.WriteLine(args.ToString());
            }

            while (true)
            {
                Thread.Sleep(1000);
                RoleManager.WriteToLog("Information", "Hello I am plugin");
                Console.WriteLine("Hello I am plugin");
            }
        }
    }
}

In the web.config file i did the following...

  <system.diagnostics>
    <sources>
      <source name="DemoPlugin" switchValue="All">
        <listeners>
          <add name="DemoPlugin" type="Plugin1.Class1"
               initializeData="Hello"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
shrimpy
A: 

I think you need to tell us what this other application will be doing. By asking the question with so much generality, you have received an answer that does not help you at all.

There are many pieces of information about a running process that can be gathered from the outside. None of these techniques require anything like what you're asking for. You can collect various performance counters; you can collection process statistics.

With a lot of work, you can gather information on many aspects of the running of a separate program. But you'll have to tell us what you're looking for before we can give it to you.

John Saunders
@ John Saunders,Thanks for you reply, what the other application does, actually is monitoring the server status information, and make some web service call send out to the repository.you can imagin like this, some people come to me, say they worrie about the resource usage of there web application, so i will think of write a application to check the server status. but some of the people host there application on premise, and some of the host on the cloud, so i`d better create a plugin which can live with there application,....
shrimpy
Ok. But this is more complicated than you may think. You're going to have a lot of trouble doing this sort of thing in Medium Trust. You're going to have trouble communicating with the plug-in, and you're not going to be able to launch a new process. You should really think of another way to do this.
John Saunders
hmm...if so...then i have to change my mind then...thanks for your advice.......i am staring from zero again then..
shrimpy