473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Trace across AppDomains

If this is simple, forgive my ignorance, but I'm coming from the
CompactFramework where we don't use AppDomains. I did a fair bit of archive
searching and couldn't find an answer and I got no responsed in the remoting
group after a week, so I'm throwing a little wider net this time.

I have a desktop app (FFx 2.0) developed with Studio 05 that loads
assemblies in a separate AppDomains from the primary UI. I'd like to be
able to hook up a TraceListener in the UI AppDomain and then get information
to it from Trace.Write in the other AppDomains.

I realize that the Trace data exists inside the individual AppDomains, but
Studio itself seems to have no problem receiving and displaying the Trace
statements from all AppDomains that I'm running, so I know that doing this
is possible.

Is there some general practice or pattern that would allow me to get the
Trace info from all AppDomains (within my actual process is fine)?
--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

Nov 16 '07 #1
3 3725
I get the distinct impression from reading your post that there is a
misunderstanding of what AppDomain really means here. When you say something
like "loads assemblies in a separate AppDomains from the primary UI", can you
be specific about what this means? How are you accessing classes and methods
in these assemblies that are in "separate AppDomains"?
If you truly have Trace data happening in a separate AppDomain, you would
need to have a mechanism that implements MarshalByRefObject (like Remoting)
semantics to marshal the data back to the other AppDomain for display. There
are a couple of other statements in your post such as "within my actual
process is fine" that further indicate there may be some confusion.

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"<ctacke/>" wrote:
If this is simple, forgive my ignorance, but I'm coming from the
CompactFramework where we don't use AppDomains. I did a fair bit of archive
searching and couldn't find an answer and I got no responsed in the remoting
group after a week, so I'm throwing a little wider net this time.

I have a desktop app (FFx 2.0) developed with Studio 05 that loads
assemblies in a separate AppDomains from the primary UI. I'd like to be
able to hook up a TraceListener in the UI AppDomain and then get information
to it from Trace.Write in the other AppDomains.

I realize that the Trace data exists inside the individual AppDomains, but
Studio itself seems to have no problem receiving and displaying the Trace
statements from all AppDomains that I'm running, so I know that doing this
is possible.

Is there some general practice or pattern that would allow me to get the
Trace info from all AppDomains (within my actual process is fine)?
--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

Nov 17 '07 #2
Sorry I wasn't clear - the app is pretty complex, but I'm fairly sure
(though not 100%) that I'm not confused about what's going on.

We have a main application that runs the UI for a large pluggable framework.
Basically it's a development environment that dynamically loads up other
assemblies. These assemblies are each hosted in a separate AppDomain and
called through a remoted interface. The methods are called via Reflection
through that remoted interface using MethodInfo and PropertyInfo pulled from
the assembly's types at load.

There's nothing that inherently makes these assemblies have to be on the
local PC - they just currently are (we're designing so they don't
necessarily have to be). We also may have some interaction with other
processes on the same machine in the future.

So if I load up the UI, and it in turn loads up an assembly through remoting
in another AppDomain, if I call Trace.Writeline the trace statements show up
in Studio. However a TraceListener on the "UI App" doesn't see it. A
TraceListener in the spawned AppDomain does, and the TraceListener in the UI
sees Traces from it's own domain - all as expected.

What I'm wondering is how exactly is Studio getting these Traces from all
AppDomains currently running under the debugged process. Is there some
standarized way to do it? Since as far as I can tell I can't remote events,
and I certainly don't want to poll all loaded assemblies across every
AppDomain we spawn (there's one per assembly and there can be a lot of
assemblies), is there a reasonably efficient mechanism to do it?

Thanks.

- Chris
"Peter Bromberg [C# MVP]" <pb*******@yahoo.NoSpamMaam.comwrote in message
news:7A**********************************@microsof t.com...
>I get the distinct impression from reading your post that there is a
misunderstanding of what AppDomain really means here. When you say
something
like "loads assemblies in a separate AppDomains from the primary UI", can
you
be specific about what this means? How are you accessing classes and
methods
in these assemblies that are in "separate AppDomains"?
If you truly have Trace data happening in a separate AppDomain, you would
need to have a mechanism that implements MarshalByRefObject (like
Remoting)
semantics to marshal the data back to the other AppDomain for display.
There
are a couple of other statements in your post such as "within my actual
process is fine" that further indicate there may be some confusion.

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"<ctacke/>" wrote:
>If this is simple, forgive my ignorance, but I'm coming from the
CompactFramework where we don't use AppDomains. I did a fair bit of
archive
searching and couldn't find an answer and I got no responsed in the
remoting
group after a week, so I'm throwing a little wider net this time.

I have a desktop app (FFx 2.0) developed with Studio 05 that loads
assemblies in a separate AppDomains from the primary UI. I'd like to be
able to hook up a TraceListener in the UI AppDomain and then get
information
to it from Trace.Write in the other AppDomains.

I realize that the Trace data exists inside the individual AppDomains,
but
Studio itself seems to have no problem receiving and displaying the Trace
statements from all AppDomains that I'm running, so I know that doing
this
is possible.

Is there some general practice or pattern that would allow me to get the
Trace info from all AppDomains (within my actual process is fine)?
--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


Nov 17 '07 #3
Chris,

There are two issues here, IMO.

The first I think, depends on the underlying store for the class that
derives from TraceListener. If the store is something that handles
concurrency well (like say, the Event log, or SQL Server) then you shouldn't
have to worry.

However, if it is something where you need to worry about concurrent
access to the underlying source, then you need to make sure that access to
that underlying store is synchronized.

This is important even if you are using the trace in the same app
domain. Of course, this is assumed, since the trace methods can be called
from any thread in the app domain.

The second issue here is the TraceListener itself. All TraceListeners
derive from MarshalByRefObject. Because of that, when creating your new
AppDomains, pass the TraceListener to your app domain and then add it to the
TraceListeners in the new app domain. This way, when the methods on the
Trace class are called in the new app domain, it will access the underlying
store in the original app domain. Since the TraceListener derives from
MarshalByRefObject, all calls made to the trace listener from the new app
domain will be marshaled to the orignal app domain.

This can, of course, have a performance impact if this is moved across
machines.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"<ctacke/>" <ctacke[at]opennetcf[dot]comwrote in message
news:un*************@TK2MSFTNGP03.phx.gbl...
Sorry I wasn't clear - the app is pretty complex, but I'm fairly sure
(though not 100%) that I'm not confused about what's going on.

We have a main application that runs the UI for a large pluggable
framework. Basically it's a development environment that dynamically loads
up other assemblies. These assemblies are each hosted in a separate
AppDomain and called through a remoted interface. The methods are called
via Reflection through that remoted interface using MethodInfo and
PropertyInfo pulled from the assembly's types at load.

There's nothing that inherently makes these assemblies have to be on the
local PC - they just currently are (we're designing so they don't
necessarily have to be). We also may have some interaction with other
processes on the same machine in the future.

So if I load up the UI, and it in turn loads up an assembly through
remoting in another AppDomain, if I call Trace.Writeline the trace
statements show up in Studio. However a TraceListener on the "UI App"
doesn't see it. A TraceListener in the spawned AppDomain does, and the
TraceListener in the UI sees Traces from it's own domain - all as
expected.

What I'm wondering is how exactly is Studio getting these Traces from all
AppDomains currently running under the debugged process. Is there some
standarized way to do it? Since as far as I can tell I can't remote
events, and I certainly don't want to poll all loaded assemblies across
every AppDomain we spawn (there's one per assembly and there can be a lot
of assemblies), is there a reasonably efficient mechanism to do it?

Thanks.

- Chris
"Peter Bromberg [C# MVP]" <pb*******@yahoo.NoSpamMaam.comwrote in
message news:7A**********************************@microsof t.com...
>>I get the distinct impression from reading your post that there is a
misunderstanding of what AppDomain really means here. When you say
something
like "loads assemblies in a separate AppDomains from the primary UI", can
you
be specific about what this means? How are you accessing classes and
methods
in these assemblies that are in "separate AppDomains"?
If you truly have Trace data happening in a separate AppDomain, you would
need to have a mechanism that implements MarshalByRefObject (like
Remoting)
semantics to marshal the data back to the other AppDomain for display.
There
are a couple of other statements in your post such as "within my actual
process is fine" that further indicate there may be some confusion.

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"<ctacke/>" wrote:
>>If this is simple, forgive my ignorance, but I'm coming from the
CompactFramework where we don't use AppDomains. I did a fair bit of
archive
searching and couldn't find an answer and I got no responsed in the
remoting
group after a week, so I'm throwing a little wider net this time.

I have a desktop app (FFx 2.0) developed with Studio 05 that loads
assemblies in a separate AppDomains from the primary UI. I'd like to be
able to hook up a TraceListener in the UI AppDomain and then get
information
to it from Trace.Write in the other AppDomains.

I realize that the Trace data exists inside the individual AppDomains,
but
Studio itself seems to have no problem receiving and displaying the
Trace
statements from all AppDomains that I'm running, so I know that doing
this
is possible.

Is there some general practice or pattern that would allow me to get the
Trace info from all AppDomains (within my actual process is fine)?
--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


Nov 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Daylor | last post by:
hi. i have mult thread vb.net application. it has 30 threads. each thread serves 1 phone caller. the question : is there a reason , to create appdomain for each Phone Service ? meaning 30...
0
by: David Levine | last post by:
This may be an easy one (I hope so). The ultimate goal I have is to be able to use binding redirects that are specific to secondary appdomains, so that each appdomain can have a unique...
0
by: Brian Takita | last post by:
Hello, I'm getting the following error at the end of this message when trying to run the ReportManager and the ReportServer: Assembly system.data.dll security permission grant set is...
1
by: billr | last post by:
hi there, I hope that someone will be able to shed some light on little old confused me. We are developing an application which will be deployed onto a Terminal Server machine. The application...
6
by: Stephen Walch | last post by:
Our application environment consists of three basic layers: 1. Third-party unmanaged DLLs that were written before the CLR was invented and maintain a significant amount of information (including...
0
by: aghalnan | last post by:
In doing some research it is said that a singleton is bounded to the appdomain that created it. But im experiencing and issue where my singleton is crossing appdomains. Now both my appDomains are...
2
by: hufman | last post by:
Hi. I need to use an object instance in 2 differnet AppDomains, meaning changing his fields and such... I tried to do it with Remoting but i couldn't find a way to refernce a specific instance...
0
by: jeremyje | last post by:
I would like to create an application where I have many concurrent processes being managed by a monitoring process. Each process that is "managed" will be invoked from an assembly dll (think...
0
by: PRR | last post by:
Here is a code i found on "how to enumerate appdomains in a current process". The original code was posted by Thomas Scheidegger Add the following as a COM reference -...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.