appdomain

Static Variable Instances and AppDomains, what is happening?

♀尐吖头ヾ 提交于 2019-11-27 04:25:11
问题 I have public static class A { public static string ConnString; } [Serializable] public class Test{ // Accesing A's field; public string ConnString{get{return A.ConnString;}set{A.ConnString=value;}} } void Main() { A.ConnString = "InitialString"; // I set A.ConnString in the current domain var newDomain = AppDomain.CreateDomain("DomNew"); Test TObj = newDomain.CreateInstanceAndUnwrap(typeof(Test).Assembly.FullName, typeof(Test).FullName) as Test ; TObj.ConnString = "NewDomainString"; // It is

Load different version of assembly into separate AppDomain

只愿长相守 提交于 2019-11-27 03:40:12
问题 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.

How can I prevent CompileAssemblyFromSource from leaking memory?

孤人 提交于 2019-11-27 03:24:26
I have some C# code which is using CSharpCodeProvider.CompileAssemblyFromSource to create an assembly in memory. After the assembly has been garbage collected, my application uses more memory than it did before creating the assembly. My code is in a ASP.NET web app, but I've duplicated this problem in a WinForm. I'm using System.GC.GetTotalMemory(true) and Red Gate ANTS Memory Profiler to measure the growth (about 600 bytes with the sample code). From the searching I've done, it sounds like the leak comes from the creation of new types, not really from any objects that I'm holding references

In .NET 4.0, how do I 'sandbox' an in-memory assembly and execute a method?

纵然是瞬间 提交于 2019-11-27 03:00:57
Here is the reason why this question was being asked: www.devplusplus.com/Tests/CSharp/Hello_World . While similar questions were asked before, the many answers online have several issues: This must be done ".Net 4.0" style, not legacy mode. The assembly is in-memory and will only be in memory, it cannot be written to the file system. I would like to limit all access to the file-system, network, etc. Something like this: var evidence = new Evidence(); evidence.AddHostEvidence(new Zone(SecurityZone.Internet)); var permissionSet = SecurityManager.GetStandardSandbox(evidence); So far, I cannot

.NET: Problem with raising and handling events using AppDomains

99封情书 提交于 2019-11-27 02:03:37
问题 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 Class B's event, the event is raised; however, the subscribing handler in the Window class is never called. There are no exceptions being thrown. If I remove

How best to communicate between AppDomains?

让人想犯罪 __ 提交于 2019-11-27 00:21:17
问题 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? 回答1: 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

AppDomain and MarshalByRefObject life time : how to avoid RemotingException?

喜欢而已 提交于 2019-11-26 23:56:30
问题 When a MarshalByRef object is passed from an AppDomain (1) to another (2), if you wait 6 mins before calling a method on it in the second AppDomain (2) you will get a RemotingException : System.Runtime.Remoting.RemotingException: Object [...] has been disconnected or does not exist at the server. Some documentation about this isse : http://blogs.microsoft.co.il/blogs/sasha/archive/2008/07/19/appdomains-and-remoting-life-time-service.aspx http://blogs.msdn.com/cbrumme/archive/2003/06/01/51466

How do I implement .net plugins without using AppDomains?

我与影子孤独终老i 提交于 2019-11-26 22:56:42
问题 Problem statement: Implement a plug-in system that allows the associated assemblies to be overwritten (avoid file locking). In .Net, specific assemblies may not be unloaded, only entire AppDomains may be unloaded. I'm posting this because when I was trying to solve the problem, every solution made reference to using multiple AppDomains. Multiple AppDomains are very hard to implement correctly, even when architected at the start of a project. Also, AppDomains didn't work for me because I

Static Fields in AppDomain

雨燕双飞 提交于 2019-11-26 22:10:44
I'm experimenting ideas around using AppDomain to manage some legacy code contains lots of static fields in a multi-threaded environment. I read answers this question: How to use an AppDomain to limit a static class' scope for thread-safe use? , thought it's quite promising and decided to try it out with a very simple class in assembly ClassLibrary1.dll: namespace ClassLibrary1 { public static class Class1 { private static int Value = 0; public static void IncrementAndPrint() { Console.WriteLine(Value++); } } } and here's my code that loads the assemblyinto 2 different app domains and invokes

How to load a .NET assembly for reflection operations and subsequently unload it?

自作多情 提交于 2019-11-26 21:54:15
I'm writing a tool to report information about .NET applications deployed across environments and regions within my client's systems. I'd like to read the values of assembly attributes in these assemblies. This can be achieved using Assembly.ReflectionOnlyLoad , however even this approach keeps the assembly loaded. The issue here is that I cannot load two assemblies that have the same name from different paths, so naturally I can't compare the same application deployed in different systems. At this point I'm assuming the solution will involve using temporary AppDomain s. Can someone detail how