Does Trace work in an assembly installed in the GAC?

  • Thread starter Thread starter Craig
  • Start date Start date
C

Craig

I have an ASP.net Web service. The web service calls an assembly that is
installed in the GAC on the deployment machine. I have configured an extra
EventLog trace listener in the web.config file. When calling Trace.Write
from the webservice I get the message in the Application Event log and also
one in DebugView (by sysinternals.com, which watches for messages from the
OutputDebugString API, that the DefaultTraceListener calls). So everything
works as expected so far. However the trace messages from the assembly
consumed by the web service that resides in the GAC never fire?

Why is this?

Thanks,
Craig
 
Hello.
Yes, Trace will work in a GAC'ed component. I have created a little app
that does just that.

I have a WebService which writes a trace to the event log and creates an
instance of a GAC'ed component. This component does a trace write to the
event log too. Both writes work.

Code for the webservice:
[WebMethod]
public void CallTraceComponent(string msg)
{
EventLogTraceListener EvlogWriter = new
EventLogTraceListener("WebServiceTracer");
System.Diagnostics.Trace.Listeners.Add (EvlogWriter);
System.Diagnostics.Trace.WriteLine(msg,"TraceTester");
EvlogWriter.Flush();
EvlogWriter.Close();
System.Diagnostics.Trace.Listeners.Remove(EvlogWriter);

TraceComp.clsTrace obj = new TraceComp.clsTrace();
obj.TraceSomething(msg);
}


Code for the GAC'ed component:
public void TraceSomething(string msg)
{
EventLogTraceListener CMPEvlogWriter = new
EventLogTraceListener("ComponentTracer");
Trace.Listeners.Add (CMPEvlogWriter);

msg = msg + " GAC'ed Component";

Trace.WriteLine(msg,"TraceTesterComponent");
CMPEvlogWriter.Flush();
CMPEvlogWriter.Close();
System.Diagnostics.Trace.Listeners.Remove(CMPEvlogWriter);
}

Please try this.
Thanks!


Thank you,
Scott Mason
Microsoft

This posting is provided "AS IS", with no warranties, and confers no rights.
 
Back
Top