-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: SitaramanM
Message 2 in Discussion

Hi   Had come across a similar post in dotnet247.  Check out the link 
http://www.dotnet247.com/247reference/msgs/30/150888.aspx           
Newsgroup - how can i add a custom trace listener to a COM+ server component, via its 
dllhost.exe.config file? 
hello. i have created a trace listener, which i want to use from multiple
processes (aspnet_wp.exe, .net windows applications, console applications,
and out-of-process server components). All processes should have the ability
to write to the same file at the same time.

to create the .net component that i want to run as a separate process - ie
an out-of-process server component - i have had to register it in COM+, and
add the following line to its assembly file:

<Assembly: ApplicationActivation(ActivationOption.Server)>

this component runs under the dllhost.exe process. i can trace from this
component without problems, providing that i add one of .Net's default
listeners to the dllhost.exe.config file (eg adding the
System.Diagnostics.TextWriterTraceListener), however, tracing does not work
if i add my own trace listener.

if i add the following lines to the server component, a
ConfigurationException is raised, with the message 'couldn't find type for
class "MyListener.CListener,MyListenerAssembly"':

Dim myListeners As TraceListenerCollection
myListeners = Trace.Listeners

The exception's stack trace shows that the exception is raised from
System.Diagnostics.DiagnosticsConfigurationHandler.HandleListeners(Hashtable
config, XmlNode listenersNode, Object context).

i have tried adding the listeners from the component's code, rather than the
config file - this works ok, as long as the component is started up from
COM+ before it is used by another process (eg a .net windows application).

my question is, how can i add a custom trace listener to a COM+ server
component, via its dllhost.exe.config file?

the exception that is raised seems to indicate that when the configuration
file is initially read, the assembly containing my listener is not being
correctly recognised, and hence the listener is not being added to the
listeners collection correctly.

-D.


      -D. [EMAIL PROTECTED]  ">[Original message clipped]

just discovered the answer through trial and error. must place the trace
listener in the GAC. the line in dllhost.exe.config must have the following
form:

<add name="TraceLog" type="CustomTraceListener.CCustomTraceListener,
CustomTraceListener, Version=1.0.1084.19613, Culture=neutral,
PublicKeyToken=aecfb8103695e6a7" initializeData="c:\TraceLog.txt" />

-D.


      -D. [EMAIL PROTECTED]  ">[Original message clipped]

just discovered the answer through trial and error. must place the trace
listener in the GAC. the line in dllhost.exe.config must have the following
form:

<add name="TraceLog" type="CustomTraceListener.CCustomTraceListener,
CustomTraceListener, Version=1.0.1084.19613, Culture=neutral,
PublicKeyToken=aecfb8103695e6a7" initializeData="c:\TraceLog.txt" />

-D.
 
       regards,   sr

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to