/////////////////////////////////////////////////////////////////////// #if APPDOMAINS || ISOLATED_INTERPRETERS || ISOLATED_PLUGINS private static string GetBasePath( Interpreter interpreter, /* OPTIONAL */ string packagePath, ref Result error ) { // // NOTE: Fetch the raw base directory for the currently executing // application binary. It is now possible to override the // value used here via the environment. // string path0 = AssemblyOps.GetAnchorPath(); if (path0 == null) { path0 = GlobalState.GetRawBinaryBasePath(); } // // NOTE: First, try to use the effective path to the core library // assembly. This is used to verify that this candidate // application domain base path contains the core library // assembly somewhere underneath it. // string path1 = GetAssemblyPath(); if (PathOps.IsUnderPath(interpreter, path1, path0)) { if ((packagePath == null) || PathOps.IsUnderPath(interpreter, packagePath, path0)) { return(path0); } } // // NOTE: Second, try to use the raw base path for the assembly. // This is used to verify that this candidate application // domain base path contains the core library assembly // somewhere underneath it. // string path2 = GlobalState.GetRawBasePath(); if (PathOps.IsUnderPath(interpreter, path1, path2)) { if ((packagePath == null) || PathOps.IsUnderPath(interpreter, packagePath, path2)) { return(path2); } } // // NOTE: At this point, we have failed to figure out a base path // for the application domain to be created that actually // contains the core library assembly. // error = String.Format( "cannot determine usable base path for the new application " + "domain for interpreter {0}, with the raw binary base path " + "{1}, assembly path {2}, and raw base path {3}", FormatOps.InterpreterNoThrow(interpreter), FormatOps.DisplayPath(path0), FormatOps.DisplayPath(path1), FormatOps.DisplayPath(path2)); return(null); }
/////////////////////////////////////////////////////////////////////// public static string GetPath( Interpreter interpreter, /* OPTIONAL */ Assembly assembly ) /* CANNOT RETURN NULL */ { // // NOTE: Fetch the base directory for the current application // domain. This will be used to check if the candidate // assembly paths are underneath it. It is now possible // to override the value used here via the environment. // string path0 = GetAnchorPath(); if (path0 == null) { path0 = GlobalState.GetAppDomainBaseDirectory(); } // // NOTE: First, try to use the current path to the assembly, // checking to make sure that it resides underneath the // base directory for the application domain. // string path1 = GetCurrentPath(assembly); if (PathOps.IsUnderPath(interpreter, path1, path0)) { return(path1); } // // NOTE: Second, try to use the original path to the assembly, // checking to make sure that it resides underneath the // base directory for the application domain. // string path2 = GetOriginalPath(assembly); if (PathOps.IsUnderPath(interpreter, path2, path0)) { return(path2); } // // NOTE: At this point, we have failed to figure out a path for // this assembly that actually resides within the current // application domain. This condition is not impossible; // however, it should not happen for the core library // assembly itself. // DebugOps.Complain(interpreter, ReturnCode.Error, String.Format( "could not determine a path for assembly {1} underneath " + "the application domain path {0}", FormatOps.DisplayPath( path0), FormatOps.DisplayAssemblyName(assembly))); // // NOTE: This method cannot return null; therefore, the legacy // return value will be used instead (i.e. the current // path to the assembly). // return(path1); }