appdomain

log4net across appdomains

I have an application which initializes log4net from one appdomain and needs to use it in another appdomain. Is it supported? If not, should I initialize log4net from each appdomain? Is there a risk in multiple initializations in the same application? Should I use the same log4net.config? ...

appdomains in COM interop

I have a .Net class that calls a c++ COM object which in turn calls another .Net class in COM. I've found that the two .Net classes are in seperate appdomains (which makes some trouble with log4net). Note they are in the same thread though. Why is this? Is there a way to ensure they will be in the same appdomain? ...

What is a .NET application domain?

In particular, what are the implications of running code in two different application domains? How is data normally passed across the application domain boundary? Is it the same as passing data across the process boundary? I'm curious to know more about this abstraction and what it is useful for. EDIT: Good existing coverage of the Ap...

Hide a base class method from derived class, but still visible outside of assembly

This is a question about tidyness. The project is already working, I'm satisfied with the design but I have a couple of loose ends that I'd like to tie up. My project has a plugin architecture. The main body of the program dispatches work to the plugins that each reside in their own AppDomain. The plugins are described with an interfa...

WCF serviceType as a singleton instance

I've created a Windows Communication Foundation service (the appDomain in this case is a Windows Forms application) that initializes its serviceType class as a singleton: Starting the service works. Making a call from a client works. But if the service makes a call to itself with the above code ("//Make the 1st call to the service?"),...

Create a WPF "control" that is run in an external process

I have a WPF app which contains a number of child controls. One of these controls hosts a third party library which underneath the covers runs some native code which throws access violations and crashes the application. Unfortunately removing the library is not an option. What I'd like to do is spin up a new windows process, host the t...

New appdomains in a VisualStudio Addin

I have a visual studio (2008) addin which creates a new appdomain. Calling "CreateInstanceAndUnwrap" does not throw an exception (and the "AssemblyResolve" event does not fire), and I get an object. That object, however, is flawed. :) Calling "GetType" on it returns a "MarshalByRefObject", and not the concrete object I created. This does...

Type.IsSubclassOf does not behave as expected

I have an application that loads assemblies and looks for types that are subclasses of a class C1 defined in another assembly A1 that the application references. I've defined a type T in A1 that is a subclass of C1 but when I load A1 using Assembly.Load(...) then call t.IsSubclassOf(typeof(C1)) on an instance of T I get false. I've notic...

What is the minimun Cross AppDomain communication performance penalty?

Hello, I am trying to minimize the performance penalty of communicating across AppDomains in the same machine. In my toy example, Class A is loaded in AppDomain 1. It creates an AppDomain 2 and loads there an instance of Class 2 (Class 2 inherits from MarshalByRef) getting back a proxy. Then Class 1 calls repeatedly a method on the prox...

What is the underlying mechanism used to communicate between .Net AppDomains in the same process?

I realize a rational knee-jerk response would be "Remoting you idiot! Read the MSDN docs." Every scrap of info I can find concerning .Net Remoting is in the context of inter-process communication: sockets, shared memory, pipes...the classics when it comes to IPC, but an AppDomain is not really a process. However, AppDomains seem to en...

Loading 2 versions of assembly at runtime

Dear all, I've been trying to crack this one over the last couple of weeks and have not found a good solution yet; hopefully I can get an answer here. I have two assemblies (ZA & ZB), both of which point to a common project/dll (ZC) but which could be on a different version (i.e. same dll name, same namespaces, some classes may be diffe...

Exception setting up handler for AppDomain.AssemblyResolve

Create a new appdomain, setup the assemblyResolve handler and you always get an exception saying 'assembly [current executing assembly] not found' what gives ? code is below string _fileName = @"c:\temp\abc123.dll"; AppDomain sandBox = AppDomain.CreateDomain("sandbox"); sandBox.AssemblyResolve += new ResolveEventHandler(sandBox_Ass...

How to pass a variable from one app domain to another

Hello. I'd like to know, if I have a variable,for example, a string, how to pass its value to my new app domain: static string _str; static void Main(string[] args) { _str = "abc"; AppDomain domain = AppDomain.CreateDomain("Domain666"); domain.DoCallBack(MyNewAppDomainMethod); AppDomain.Unload(domain); Console.Write...

Passing values back and forth appdomains

Hello. I have the following code: public class AppDomainArgs : MarshalByRefObject { public string myString; } static AppDomainArgs ada = new AppDomainArgs() { myString = "abc" }; static void Main(string[] args) { AppDomain domain = AppDomain.CreateDomain("Domain666"); domain.DoCallBack(MyNewAppD...

Is AppDomain equivalent to a Process for .NET code?

I have to call some badly written 3rd party COM components that have memory leaks and uses Single Threaded Apartment [STA] within a long running process. I know separate process will be nice way to implement it and I can restart it occasionally from the long running process. Can AppDomain be used instead? Is AppDomain thread a STA thre...

AppDomains and licence files

Hi, We have a dll which uses a third party component, with embedded licence file (licx). now we are trying to use our dll in a windows service applicaiton, using mulitple appdomains. the code get compiled. but when im running it im getting an error message, saying cannot find the runtime licence. could someone explain me this. when us...

.NET: Problem with raising and handling events using AppDomains

Here is the basic gist of my problem: My main Window class instantiates Class A. Class A instantiates Class B in a secondary AppDomain. Class B raises an event and Class A handles the event successfully. Class A raises an event of its own. Problem: In step 4, when Class A raises its own event from the event handler method that caught...

How to set App.Config from the Network share.

Is there way to set the App.Config file from the network share instead of providing it from the same directory where the .EXE is running. For example, Can I do something like this : System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile = @"\\abc.com\root\myshare\it\development\T\_test2\App.Config"; and at runtime ...

Can I tell Castle Windsor to create a component in a separate AppDomain?

I've created a multi-threaded service that uses Castle Windsor to create components to run on separate threads. I Resolve an component by name with parameters for each thread. I'm running into concurrency problems with a 3rd party library used by the components. I suspect that isolating those components in separate AppDomains will resol...

Retrofitting AppDomains into legacy systems

What are the guidelines to consider when "wrapping" portions of an existing / legacy system in AppDomains; we have a scenario where we essentially load plug-ins to the current AppDomain and therefore can't unload them (and also can't clean up their resource leaks), we'd like to load them in their own AppDomain to help with resource clean...