appdomain

In .Net is the 'Staticness' of a public static variable limited to an AppDomain or the whole process?

烂漫一生 提交于 2019-11-29 10:53:49
Is one copy of a public static variable created for each AppDomain in a process or is it just one copy for the whole process? In other words if I change the value of a static variable from within one AppDomain, will it affect the value of the same static variable within another AppDomain in the same process? It is per application domain as proven by this example: public class Foo { public static string Bar { get; set; } } public class Test { public Test() { Console.WriteLine("Second AppDomain: {0}", Foo.Bar); } } class Program { static void Main() { // Set some value in the main appdomain Foo

How do I pass references as method parameters across AppDomains?

痞子三分冷 提交于 2019-11-29 10:07:19
I have been trying to get the following code to work(everything is defined in the same assembly) : namespace SomeApp{ public class A : MarshalByRefObject { public byte[] GetSomeData() { // } } public class B : MarshalByRefObject { private A remoteObj; public void SetA(A remoteObj) { this.remoteObj = remoteObj; } } public class C { A someA = new A(); public void Init() { AppDomain domain = AppDomain.CreateDomain("ChildDomain"); string currentAssemblyPath = Assembly.GetExecutingAssembly().Location; B remoteB = domain.domain.CreateInstanceFromAndUnwrap(currentAssemblyPath,"SomeApp.B") as B;

Communication between AppDomains

人走茶凉 提交于 2019-11-29 07:46:49
We are building an app (WinForms, .NET 3.5) that loads "Plugin" DLLs into a secondary AppDomain. The secondary AppDomain needs to communicate occasionally with the 1st one (more specifically, call or get data from objects that are created in the main AppDomain). I have read most of the material about AppDomains and communication between them. So far, the only easy solution i've seen was inheriting from MarshalByRefObject and passing a TransparentProxy into the 2nd AppDomain, calling methods on the Proxy. This method has its drawbacks (not always possible to inherit from MBRO in case of

Can you modify the web.config and NOT restart the ASP.NET application? [duplicate]

时光毁灭记忆、已成空白 提交于 2019-11-29 07:37:31
Possible Duplicate: How to prevent an ASP.NET application restarting when the web.config is modified? Was just thinking about uptime. Thanks. SLaks Yes, you can; see this answer . However, it is not a good idea. Until ASP.Net restarts the AppDomain, it will not look at web.config . If you change web.config , your changes will have no effect until the AppDomain is restarted. You can create an external settings file and then reference it in your web.config. You will need to change the attribute "restartOnExternalChanges" to false in your machine.config file. See: http://msdn.microsoft.com/en-us

How to properly unload an AppDomain using C#?

烈酒焚心 提交于 2019-11-29 03:01:45
I have an application that loads external assemblies which I have no control over (similar to a plugin model where other people create and develop assemblies that are used by the main application). It loads them by creating new AppDomains for these assemblies and then when the assemblies are done being used, the main AppDomain unloads them. Currently, it simplistically unloads these assemblies by try { AppDomain.Unload(otherAssemblyDomain); } catch(Exception exception) { // log exception } However, on occasion, exceptions are thrown during the unloading process specifically

Message Pumps and AppDomains

一曲冷凌霜 提交于 2019-11-29 02:38:48
I have a a C# (FFx 3.5) application that loads DLLs as plug-ins. These plug-ins are loaded in separate AppDomains (for lots of good reasons, and this architecture cannot change). This is all well and good. I now have a requirement to show a Dialog from one of those plug-ins. Bear in mind that I cannot return the dialog Form to the main application and have it displayed there (the current infrastructure doesn't support it). Failure 1 In my DLL I created a Form and called Show. The dialog outline showed up but did not paint and it doesn't respond to mouse events. I assumed that this is becasue

AppDomain.CreateInstanceFromAndUnwrap - Unable to cast transparent proxy

对着背影说爱祢 提交于 2019-11-28 23:13:33
I'm writing a .NET library to inject managed DLLs into external processes. My current approach is: Use CreateRemoteThread to force the target process to call LoadLibrary on an unmanaged bootstrap DLL. From this point we're executing code in the target process. My bootstrap DLL then creates an instance of the CLR and calls ExecuteInDefaultAppDomain on it, which executes a method in a managed helper DLL. This method creates a new AppDomain and calls AppDomain.CreateInstanceFromAndUnwrap to pass execution into my payload DLL, casting the result as an IInjectionPayload . The idea is that my

Load Assembly in New AppDomain without loading it in Parent AppDomain

百般思念 提交于 2019-11-28 22:42:53
问题 I am attempting to load a dll into a console app and then unload it and delete the file completely. The problem I am having is that the act of loading the dll in its own AppDomain creates a reference in the Parent AppDomain thus not allowing me to destroy the dll file unless I totally shut down the program. Any thoughts on making this code work? string fileLocation = @"C:\Collector.dll"; AppDomain domain = AppDomain.CreateDomain(fileLocation); domain.Load(@"Services.Collector"); AppDomain

Can I make the default AppDomain use shadow copies of certain assemblies?

放肆的年华 提交于 2019-11-28 21:40:42
A short explanation of why I want to do this: I am busy writing a plugin for Autodesk Revit Architecture 2010. Testing my plugin code is extremly cumbersome, as I have to restart Autodesk for each debug session, manually load a Revit project, click on the Add-Ins tab and then start my plugin. This is just taking too long. I have written a second plugin that hosts an IronPython interpreter. This way, I can play around with the API provided by Revit. But eventually, the code has to be rewritten in C# - and debugged. Easy, I thought: Just load the plugins DLL from the IronPython script and

Unload event for the default Application Domain?

孤人 提交于 2019-11-28 12:42:00
Is there an Unload event, or any event, notification, message, mechanism, or hook, that i can use to be notified before the "default" application domain is unloaded? i have code that needs to know when the application domain (almost always the default domain) is ending. Note: i don't know what kind of application a developer will be creating when he uses my code. It could be: a console application a WinForms application an ASP.net application an ASP.net web-site Runtime Callable Wrapper (RCW) COM object a Windows Explorer shell extension or a Windows Service Either way, i need to know when the