Restrict plugin access to file system and network via appdomain

For .net framework 4.0, please follow the following code from this MSDN article. The following example implements the procedure in the previous section. In the example, a project named Sandboxer in a Visual Studio solution also contains a project named UntrustedCode, which implements the class UntrustedClass. This scenario assumes that you have downloaded a library … Read more

ASP.NET restarts when a folder is created, renamed or deleted

This code appears to resolve the issue, when added to Application_Start() in Global.asax: PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty(“FileChangesMonitor”, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); object o = p.GetValue(null, null); FieldInfo f = o.GetType().GetField(“_dirMonSubdirs”, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase); object monitor = f.GetValue(o); MethodInfo m = monitor.GetType().GetMethod(“StopMonitoring”, BindingFlags.Instance | BindingFlags.NonPublic); m.Invoke(monitor, new object[] { }); http://dotnetslackers.com/Community/blogs/haissam/archive/2008/11/12/disable-session-expiration-when-using-directory-delete.aspx With these … Read more

What is a .NET application domain?

An AppDomain basically provides an isolated region in which code runs inside of a process. An easy way to think of it is almost like a lighter-weight process sitting inside of your main process. Each AppDomain exists within a process in complete isolation, which allows you to run code safely (it can be unloaded without … Read more

List AppDomains in Process

You may want to look at this post using System.Runtime.InteropServices; // Add the following as a COM reference – C:\WINDOWS\Microsoft.NET\Framework\vXXXXXX\mscoree.tlb using mscoree; public static IList<AppDomain> GetAppDomains() { IList<AppDomain> _IList = new List<AppDomain>(); IntPtr enumHandle = IntPtr.Zero CorRuntimeHostClass host = new mscoree.CorRuntimeHostClass(); try { host.EnumDomains(out enumHandle); object domain = null; while (true) { host.NextDomain(enumHandle, out domain); … Read more

Static Fields in AppDomain

It looks like you are loading a type from another appDomain into the current appDomain. Thus the code that calls the static methods are calling from the current appDomain. I’m unaware of any other way to call a static method in another domain without creating an instance of an object in another domain, and having … Read more