appdomain

Running a runtime compiled C# script in a sandbox AppDomain

旧城冷巷雨未停 提交于 2019-12-11 04:17:42
问题 My application should be scriptable by the users in C#, but the user's script should run in a restricted AppDomain to prevent scripts accidentally causing damage, but I can't really get it to work, and since my understanding of AppDomains is sadly limited, I can't really tell why. The solution I am currently trying is based on this answer https://stackoverflow.com/a/5998886/276070. This is a model of my situation (everything except Script.cs residing in a strongly named assembly). Please

Load Assembly into a new app domain but not CurrentDomain

天大地大妈咪最大 提交于 2019-12-11 04:08:07
问题 So my problem revolves around saving memory. In essence I need to load an assembly in to a separate app domain other than the main/current domain, check for types within that assembly, and then unload the new domain when done. Currently my solution is as follows: AppDomain NewDomain = AppDomain.CreateDomain("newdomain"); foreach(string path in dllPaths) //string list of dll paths { byte[] dllBytes = File.ReadAllBytes(dll); NewDomain.Load(dllBytes); //offending line } DoStuffWithNewDomain();

Passing collection objects back and forth between appdomains

删除回忆录丶 提交于 2019-12-11 03:55:41
问题 The following sample is based on "Passing values back and forth appdomains", where Marc Gravell kindly provided a very good answer to a question about .Net remoting between appdomains. What I've done is extended it in a (very naive?) expectation that it should also work for an array of strings. The problem is that it only works one way - the created appdomain can access the array, but only readonly. What I'd like is to get the updated array elements back in the original appdomain too. I'd

Why is AssemblyResolve called when Assembly is in CurrentDomain?

ε祈祈猫儿з 提交于 2019-12-11 01:41:33
问题 I have a situation where AppDomain.CurrentDomain.AssemblyResolve is called for an assembly that has already been loaded into the current domain using Assembly.Load(myAssemblyMemStream.ToArray()) . Why is that? I need to do the following to get it to work. How does this differ from what .NET does automatically? Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { return AppDomain.CurrentDomain .GetAssemblies() .First(x => x.FullName == args.Name); } 回答1: Load contexts

Failed to load C module in new appdomain

梦想的初衷 提交于 2019-12-11 01:14:02
问题 I have some .NET code that need to run in a separate AppDomain, and everything goes well except when there is call of COM component. To make it clear, I wrote a very simple repro as below: AppDomain ap = AppDomain.CreateDomain("newap"); ap.DoCallBack( () => { //GroupPolicyObject is from assembly microsoft.grouppolicy.management.interop.dll GroupPolicyObject newGPO = new GroupPolicyObject(); }); The exception: System.TypeInitializationException: The type initializer for '' threw an exception.

Should ApplicationBase be different for the sandbox AppDomain?

只谈情不闲聊 提交于 2019-12-10 23:38:32
问题 What are the exact security implications of setting ApplicationBase of a slave sandbox domain to the same path as the hosting domain? I found MSDN guidelines that state that ApplicationBase should be different for the slave domain "If the ApplicationBase settings are the same, the partial-trust application can get the hosting application to load (as fully trusted) an exception it defines, thus exploiting it" (p. 3): http://msdn.microsoft.com/en-us/library/bb763046.aspx How exactly would this

Rebus, exception when creating AppDomain / Instance from async Handler

南笙酒味 提交于 2019-12-10 23:31:02
问题 We have a problem with the new (async) version of Rebus that didn’t exist with the older version. When handling rebus message and trying to create AppDomain and Instance to run plugin code dynamically, it always give me an exception. To make the example as simple as possible, I made a Test method: public static void Test() { AppDomain ad = AppDomain.CreateDomain("Test"); Loader loader = (Loader)ad.CreateInstanceAndUnwrap(typeof(Loader).Assembly.FullName, typeof(Loader).FullName); } class

Unloading Application Domain does not return?

末鹿安然 提交于 2019-12-10 21:31:22
问题 My question is about application domain created for loading/unloading dlls. All started with the need of Step-1 : load the dll Step-2 : process that dll Step-3 : Unload the dll As we can not unload a dll, creating an Application Domain is inevitable, which is fine. So new steps are; Step-1 : Create a new app domain Step-2 : load the dll Step-3 : process that dll Step-4 : Unload the Application domain My problem is about unloading part. Sometimes AppDomain.Unload("newDomain"); does not return

Is it possible to load an assembly targeting a different .NET runtime version in a new app domain?

六月ゝ 毕业季﹏ 提交于 2019-12-10 19:34:27
问题 I've an application that is based on .NET 2 runtime. I want to add a little bit of support for .NET 4 but don't want to (in the short term), convert the whole application (which is very large) to target .NET 4. I tried the 'obvious' approach of creating an application .config file, having this: <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> </startup> but I ran into some problems that I noted here. I got the idea of creating a separate app domain. To

ASP.net UserControl and AppDomain TypeResolve

ⅰ亾dé卋堺 提交于 2019-12-10 15:53:29
问题 I'm using a VirtualPathProvider to include usercontrols that are not available at compile-time. Everything is working correctly except for the reference to the dll that actually contains the control. When the page that has the control is called it can't find the control type unless I put the dll on the bin folder. Error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and