appdomain

Load a WPF application Assembly from another WPF app, get error: Cannot create more than one System.Windows.Application instance in the same AppDomain

亡梦爱人 提交于 2019-12-10 15:27:09
问题 The Scenario: LUNCHER.exe : a WPF Application >> Build 32bit , .Net 4.5.1 , location= D:\ LOADED.exe : another WPF Application >> Build 32bit , .Net 4.5.1, location= D:\ I'm owner of both assembly (both application and thair sources) Now, i want load the LOADED.exe [and its resources such as images dlls and...) as a Byte array to the memory and execute it, then remove LOADED.exe and its resources from hard disk. In the first step i'm trying to just load the LOADED.exe file to memory and

C# Loading a DLL byte array into a different AppDomain throws System.IO.FileNotFoundException

安稳与你 提交于 2019-12-10 12:06:27
问题 I am trying to load a DLL file that has been copied into a byte array into a new AppDomain. The DLL does contain references to things like Windows.Forms and other dlls. Are those the ones failing to load? If so how do you pre-load them for that specific domain? AppDomainSetup Setup = new AppDomainSetup(); Setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; Setup.ApplicationName = "Plugin_" + DLLName + "" + PluginManager.PluginList.Count; AppDomain Domain = AppDomain.CreateDomain(

How do appDomain provide Isolation

核能气质少年 提交于 2019-12-10 11:38:49
问题 In my window forms application, I create a Appdomain say sandBox. In this sandbox i excute some code Say TestMethod from TestAppdomain Class. This class is in Test.dll which is not loaded in the current appdomain (Default appdomain). Now while executing TestMethod some exception occurs, then I want the sandbox domain to be unloaded and since AppDOmain provide Isolotion my Default Appdomain shoud not be affected. But As i read over the internet i guess this is not possible.But could some one

Is it possible to have delegates marshalled as proxies when they are passed across to another AppDomain?

时间秒杀一切 提交于 2019-12-10 11:24:34
问题 Somehow I assumed that delegates passed to another AppDomain would turn into a proxy as if it were an object derived from MarshalByRefObject . Unfortunately, it seems they don’t. Let’s say in my code I have a class MyClass like this: [Serializable] public sealed class MyClass { public Func<Input, Output> SomeDelegate; } [Serializable] public sealed class Input { ... } [Serializable] public sealed class Output { ... } Now I need to pass an instance of MyClass to another AppDomain. The problem

Create .NET 2.0 AppDomain in .NET 4.0 process

风流意气都作罢 提交于 2019-12-10 11:07:36
问题 I need to dynamically create a .NET 2.0 compatible assembly from within my .NET 4.0 process. Currently it is achieved with this: AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(...) ModuleBuilder mb = assemblyBuilder.DefineDynamicModule(...); But unfortuntely all dll's produced are .NET 4.0 (inherited from my 4.0 process) which doesn't work with my other .NET 2.0 processes. Any idea how 2 different CLR versioned AppDomains can co-exist in the same process? 回答1: Have a look

WPF warm AppDomain startup performance (Application.RunInternal, XamlReader.LoadBaml)

℡╲_俬逩灬. 提交于 2019-12-10 10:44:39
问题 I have relatively simple application, but warm (second, etc.) start-up time is awful 3-5 seconds. Profiler (VS2010, CPU Sampling) shows that more than 80% of time is spent in Application.RunInternal (~40%) and XamlRader.LoadBaml (~40%) functions. The root of the problem is that Window is created in non-default AppDomain. If I move Window creation to default AppDomain or give AppDomain unrestricted permission set everything is as fast as expected. I'm testing on: Windows Seven x64 .Net 4.0 4Gb

AppDomains vs. a robust server

試著忘記壹切 提交于 2019-12-10 09:39:09
问题 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 hosts a service which leaks exceptions this will bring down the default AppDomain as well. So I guess from a server architecture point-of-view there is nothing better

Restricted Permission AppDomain Grant Set Issue

依然范特西╮ 提交于 2019-12-10 09:31:25
问题 I have some code that dynamically compiles a Razor templates into an Assembly which I execute with a set of permissions (no access to files, etc). This works on our development computers and on our test server (Windows 2008 IIS7 x64 .NET 4). But on our production server (Same spec) it gives the error: "Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)" Here is the code: - public static SandboxContext Create(string

List all custom data stored in AppDomain

霸气de小男生 提交于 2019-12-10 03:14:20
问题 In order to store the state of processes when an error occured, I would like to list all (custom) data stored in AppDomain (by SetData). The LocalStore property is private and AppDomain class not inheritable. Is there any way to enumerate those data ? 回答1: AppDomain domain = AppDomain.CurrentDomain; domain.SetData("testKey", "testValue"); FieldInfo[] fieldInfoArr = domain.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance); foreach (FieldInfo fieldInfo in fieldInfoArr) { if

Using AppDomains to Parallelize Non-thread-safe DLL

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-09 17:31:47
问题 I have an unmanaged C++ DLL that my .NET application uses via p/invoke. The method that I need from this DLL is fairly time consuming and I would like to parallelize the method calls. The problem is that it uses a bunch of statics and globals, so it is not thread-safe (and can't be changed). My plan was to overcome this non-thread-safe issue by calling the unmanaged DLL from multiple AppDomains in parallel. I can call the unmanaged code from the multiple AppDomains without any problems as