appdomain

How to load an assembly as reflection-only in a new AppDomain?

梦想与她 提交于 2019-12-29 09:14:08
问题 I'm experienced in C# but relatively unfamiliar with the concepts of AppDomain and the like. Anyway, I'm trying to get an assembly to load in a reflection-only context so I can grab all of its namespaces. Here is the code I have right now (warning: PowerShell): function Get-Namespaces($assembly) { $assemblyClass = [Reflection.Assembly] $winmdClass = [Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMetadata] $domain = [AppDomain]::CurrentDomain # Since desktop .NET can't work with winmd

AppDomain.CreateInstanceFromAndUnwrap - Unable to cast transparent proxy

穿精又带淫゛_ 提交于 2019-12-29 04:34:07
问题 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

How to reload an assembly for a .NET Application Domain?

谁说我不能喝 提交于 2019-12-28 18:08:37
问题 We are loading an assembly (a DLL) which reads a configuration file. We need to change the configuration file and then re-load the assembly. We see that after loading the assembly the 2nd time, there is no change in the configuration. Anyone see what is wrong here? We left out the details of reading in the configuration file. AppDomain subDomain; string assemblyName = "mycli"; string DomainName = "subdomain"; Type myType; Object myObject; // Load Application domain + Assembly subDomain =

Good example of use of AppDomain

倖福魔咒の 提交于 2019-12-28 07:40:08
问题 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:

Pass and execute delegate in separate AppDomain

試著忘記壹切 提交于 2019-12-28 04:50:08
问题 I want to exceute some piece of code in separate AppDomain with delegate. How can I do this? UPD1 : some more details about my problem My program processing some data (one iteration is: get some data from DB, evaluate it and create assemblies at runtime, execute dynamic assemblies and write results to DB). Current solution: each iteration running in separate thread. Better solution: each iteration running in separate AppDomain (to unload dynamic asseblies). UPD2 : All, thanks for answers. I

Create custom AppDomain and add assemblies to it

大憨熊 提交于 2019-12-28 04:15:11
问题 How can I create an appdomain, add assemblies to it, then destroy that app domain? This is what I have tried: static void Main(string[] args) { string pathToExe = @"A:\Users\Tono\Desktop\ConsoleApplication1.exe"; AppDomain myDomain = AppDomain.CreateDomain("MyDomain"); Assembly a = Assembly.Load(System.IO.File.ReadAllBytes(pathToExe)); myDomain.Load(a.FullName); // Crashes here! } I have also tried: myDomain.Load(File.ReadAllBytes(pathToExe)); how can I add an assembly to the appdomain. Once

Assembly.Load duplicates the Assembly when loaded into a new AppDomain

谁说胖子不能爱 提交于 2019-12-25 14:39:16
问题 I currently have a problem where if I set up a new App Domain and use AppDomain.Load , The Assembly gets loaded twice (Once into the new App Domain, and once into the default App Domain) The code I am using to load the Assembly is as follows: AppDomain dom = AppDomain.CreateDomain(_dllname); AssemblyName assemblyName = new AssemblyName(); assemblyName.CodeBase = directory + _dllname; Assembly a = dom.Load(assemblyName); When I use this code the Assembly loads correctly into my new AppDomain

AppDomain.ActivationContext is NULL

一曲冷凌霜 提交于 2019-12-25 02:24:37
问题 I have created an AppDomain in my application. Below is the code I have used AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = "C:\\"; AppDomain domain = AppDomain.CreateDomain("MyDomain", null, domaininfo); ActivationContext context = domain.ActivationContext; But the ActivationContext is null in above snippet. Can anyone help me on this. Thanks in Advance. 回答1: It's null by default if you don't specify an ActivationContext . If you want an ActivationContext ,

Can't set synchronization context when using appdomains

无人久伴 提交于 2019-12-25 01:47:12
问题 I have a custom framework where a host application runs an event loop and loads a guest application into a separate app-domain. The guest application has means to take advantage of the event loop via a provided API. I want to make the guest application be able to automatically propagate all continuations onto the event loop much like it's done in .NET GUI applications and the UI thread. Therefore, I create a custom synchronization context which is able to do that. But the problem is I can't

Pointing domain name to azure traffic manager URL instead of directly to server IP

梦想的初衷 提交于 2019-12-25 01:33:44
问题 So I have a domain badgag.com That points to an IP of the current server. But I want it instead to point to http://badgag.trafficmanager.net/ This DNS will route to the server with the lowest latency. So I try to change mapping to badgag.com -> badgag.trafficmanager.net -> closest web app -> IP But I am not sure what A, cname etc records I need to change. This is how it looks now: A @ 104.45.14.249 1 time CNAME autoconfig @ 1 time CNAME autoconfig.admin @ 1 time CNAME autodiscover @ 1 time