appdomain

Load different version of assembly into separate AppDomain

﹥>﹥吖頭↗ 提交于 2019-11-28 10:32:05
I'm implementing application that supports plugins. Currently the problem arises when I try to load common assembly that is used both by host application and plugin: host application should use one version of that assembly, while plugin uses another version. This is dictated by application upgrade process - plugin can be updated separately from host application. Every assembly is signed, so I use strong names for loading assemblies. I created a test application which demonstrates the problem. Plugin assemblies are located in subfolder 'Plugin' of host application. Plugin folder contains the

Help needed with unloading .DLL's from AppDomain - Still not working even with ShadowCopy

有些话、适合烂在心里 提交于 2019-11-28 08:57:36
问题 I am trying to do the following. App A is the "mother app". It stays open. App B is just a .DLL where I write some classes that are derived from an interface specified in App A. Then, from App A, I will "import" classes from App B and run methods within them. I want to be able to dynamically change App B (change code and recompile) and use the new code in App A. I have a post-compile command in App B that copies the new .DLL to the App A directory. App A creates a new AppDomain and uses

What happens to the static data in a class if it is accessed across app domains?

吃可爱长大的小学妹 提交于 2019-11-28 07:54:15
问题 I have a static class which has some static data. What happens to the data if its accessed from different app domain? Will there a copy of a static class for each domain? Will the primitive types be copied? What if the data is serializable? 回答1: The memory between AppDomain's is not shared. By default the objects are a deep clone, if they are MarshalByRef then its similar to remoting where the calls are executed across AppDomain, so it appears that its shared state. MarshalByRefObject is the

Can I prevent an uncaught exception in another AppDomain from shutting down the application?

限于喜欢 提交于 2019-11-28 07:24:10
问题 I'm having trouble with a misbehaved library that throws an exception in a finalizer, which of course crashes the application. To avoid this, I tried loading the library in its own AppDomain, but the exception still bubbles to the surface and crashes the application. As documented on MSDN, registering to AppDomain.UnhandledException doesn't prevent the exception from bubbling up, but I'm quite surprised that there is no other way to catch such an exception in a "sub AppDomain". How do plugin

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

最后都变了- 提交于 2019-11-28 04:32:06
问题 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? 回答1: 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

How best to communicate between AppDomains?

放肆的年华 提交于 2019-11-28 04:30:01
I have an application that needs to send a moderately high volume of messages between a number of AppDomains. I know that I could implement this using remoting, but I have also noticed that there are cross-domain delegates. Has anyone looked at this kind of problem? Michael Meadows I have had good success using WCF with a named pipes binding. Using named pipes creates no network traffic and uses binary encoding, so it should be pretty fast without sacrificing the ability to distribute in future scaling scenarios. EDIT: Refer here for more detailed information including a link to an

No AppDomains in .NET Core! Why?

故事扮演 提交于 2019-11-28 04:03:18
Is there a strong reason why Microsoft chose not to support AppDomains in .NET Core? AppDomains are particularly useful when building long running server apps, where we may want to update the assemblies loaded by the server is a graceful manner, without shutting down the server. Without AppDomains, how are we going to replace our assemblies in a long running server process? AppDomains also provide us a way to isolate different parts of server code. Like, a custom websocket server can have socket code in primary appdomain, while our services run in secondary appdomain. Without AppDomains, the

How to detect when application terminates?

我是研究僧i 提交于 2019-11-28 03:32:27
This is a follow up to my initial question and I would like to present my findings and ask for corrections, ideas and insights. My findings (or rather interpretations) come from people's answers to my previous question, reading MSDN .NET 3.5 documentation and debugging .NET 3.5 code. I hope this will be of value to someone who was wondering like me how to detect when an application terminates. Events: System.AppDomain.CurrentDomain.ProcessExit : raised when process exits, e.g. after the default AppDomain and everything else was unloaded [Total execution time is limited to just 3 seconds!]. For

How do I pass references as method parameters across AppDomains?

大憨熊 提交于 2019-11-28 03:25:18
问题 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()

Good example of use of AppDomain

匆匆过客 提交于 2019-11-28 03:02:09
I keep getting asked about AppDomains in interviews, and I know the basics : they are an isolation level within an application (making them different from applications) they can have threads (making them different from threads) exceptions in one appdomain do not affect another appdomains cannot access each other's memory each appdomain can have different security I still don't get what makes them necessary. I'm looking for a reasonable concrete circumstance when you would use one. Answers: Untrusted code Core application protected Untrusted/3rd party plugins are barred from corrupting shared