appdomain

Unload CodeDom-compiled assembly

I have some C# code (let's call it "script") I am compiling at runtime. It uses an interface in my main program that I use to access its functions. Once compiling is done I have CompilerResults.CompiledAssembly in which case I can CreateInstance(Type). Once I am done using the script I would like to unload completely. From what I und...

How to access WPF controls from standard CS file

Hello there, Again, need your hands. I have one WPF application that will invoke some methods hosted in second AppDomain, now, I want to access one WPF control (ProgressBar) from one separate class file(not code-behind), which extends from MarshalByRefObject, I need to do this like below: using System; using System.Collections.Generic...

Failure to use AppDomain from COM interop

I've a piece of .NET code that for various reasons (reliability, deployment) must run in a separate AppDomain. I've created a proxy object deriving from MBR that delegates the calls to the real stuff so it wont load in the current AppDomain. I create the proxy via the usual CreateInstanceAndUnwrap. this.eDirectCommunication = (EDirectCo...

My app domain won't unload

At runtime, I'd like to be able to unload a DLL and reload a modified version of it. My first experiment went down in flames. Can anyone tell me why? Thanks in advance! private static void Main() { const string fullPath = "C:\\Projects\\AppDomains\\distrib\\MyLibrary.dll"; // Starting out with a version of MyLibrary.dll which o...

AppDomains vs. a robust server

Hi all, after doing some research it seems that AppDomains are not really a tool for building a hosting server. From my understanding, the hosting server will still crash if there is an unhandled exception in a created AppDomain (if the exception is thrown from a thread in the created AppDomain). So in that case if the hosting server ho...

Replacing Process.Start with AppDomains

Background I have a Windows service that uses various third-party DLLs to perform work on PDF files. These operations can use quite a bit of system resources, and occasionally seem to suffer from memory leaks when errors occur. The DLLs are managed wrappers around other unmanaged DLLs. Current Solution I'm already mitigating this is...

How do I create a restricted AppDomain?

I need to run some user-generated code. Needless to say, I don't want them doing anything interesting like opening files or access web sites. I hear that I can create a locked-down AppDomain that prohibits all this, but I don't know how to set it up. ...

Restrict plug-in assembly code access.

I'd like to create a plug-in architecture where I can limit an assemblies API to something very restricted, i.e. only allow a whitelist of functions. Is it possible to restrict what functions/methods a plug in assembly can call? Can I do it using AppDomains? Does anyone have a simple example? ...

Is the any free library that implements message queuing similar to MSMQ (Microsoft Message Queuing)?

I am interested in using a free library that has features similar to MSMQ to send/receive messages among 3 app domains in a win form application. I only need the private queue functionality (No public queues or AD support) Please provide links and some advantages/disadvantages . I am happy to open sub questions if you think you need more...

How to represent AppDomain in ASP.NET ?

Recently i attentened an interview.I have been asked to explain the "Application Domain" and the special purpose about the introduction of "application domain". I explained : AppDomain is a runtime representation of a logical process withing a physical process (win32) managed by CLR. Special purpose : Keeps high level application iso...

Multiple Assembly.Load(Byte[]), same instance or leak ?

What happens when I call Assembly.Load(Byte[]) multiple times with a Byte array containing the same assembly ? Will I get the same instance of Assembly for each call ? The same assembly loaded multiple times within the app domain ??? ...

How should I gracefully handle faulty AppDomains?

Is this code snippet poorly designed? Originally, there was only one AppDomain.Unload, in the finally block. This had the unfortuanate side effect that other threads could keep running in the AppDomain while UnhandledException was running, which among other things uses user input and is hence very slow on a computing scale (average real ...

Remoting and missing channel sinks

I ran into a remoting exception: "This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server." The cause is best explained by this blog entry I found: The second case is more obscure. This occ...

How to detect that there are no appdomain proxy objects left

I have a system which loads assemblies into an appdomain and then hands out object proxies to other domains (basically a simple IoC container). We need to achieve very high uptime, and being able to update implementations at runtime helps this a lot. I've go no problems with this in that I can fire up a new appdomain, load new assemblie...

Assemblies mysteriously loaded into new AppDomains

I'm testing some code that does work whenever assemblies are loaded into an appdomain. For unit testing (in VS2k8's built-in test host) I spin up a new, uniquely-named appdomain prior to each test with the idea that it should be "clean": [TestInitialize()] public void CalledBeforeEachTestMethod() { AppDomainSetup appSetup = new A...

How to unload assemblies from the GAC?

I am trying to run automated tests on a particular product. The test consists of installing the product into different locations on the hard drive and then performing some operations on it and then closing the application. The code that launches the process looks like this: using (Process process = new Process()) { ...

Waiting for Appdomain code to finish

Hi, I'm creating an Appdomain to run a piece of code that can literally be any thing. I want my host process to be able when all the word is complete but async calls/threads are blocking my efforts. My code is something like this: AppDomain ad = AppDomain.CreateDomain(...); WorkUnit mbro = (WorkUnit)ad.CreateInstanceAndUnwrap(...); mb...

Exception caused by AppDomain when it shouldn't?

I am working on my MCTS and currently studying the AppDomain functionality. But I am running into something unclear. AppDomain should be capturing Exception and allow the domain to safely unload. (With the possible exception of the StackOverflowException as suggested elsewhere) AppDomainSetup setup = new AppDomainSetup(); setup.Applicat...

.Net How to create a custom ThreadPool shared across all the AppDomain of a process?

I made a custom ThreadPool optimized for my specific needs. However, when there are multiple AppDomains in the process, the CLR ThreadPool is able to be shared across all the AppDomains and I would like to be able to reproduce this behavior. This could be done using MarshalByRefObject and Remoting in order to create a distributed Thread...

ASP.NET Data Cache - preserve contents after app domain restart

I am using ASP.NET's data caching API. For example: HttpRuntime.Cache.Insert(my_data, my_key); Is there any way to configure cache so its contents are preserved when the App Domain recycles? I load many object into cache, but there is a substantial delay re-loading these every time the app domain restarts. Assume for this question th...