示例#1
0
        public static Object CreateApplicationHost(Type hostType, String virtualDir, String physicalDir)
        {
#if !FEATURE_PAL // FEATURE_PAL does not require PlatformID.Win32NT
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                throw new PlatformNotSupportedException(SR.GetString(SR.RequiresNT));
            }
#else // !FEATURE_PAL
            // FEATURE_PAL
#endif // !FEATURE_PAL

            if (!StringUtil.StringEndsWith(physicalDir, Path.DirectorySeparatorChar))
            {
                physicalDir = physicalDir + Path.DirectorySeparatorChar;
            }

            ApplicationManager appManager = ApplicationManager.GetApplicationManager();

            String appId = StringUtil.GetNonRandomizedHashCode(String.Concat(virtualDir, physicalDir)).ToString("x");


            ObjectHandle h = appManager.CreateInstanceInNewWorkerAppDomain(
                hostType, appId, VirtualPath.CreateNonRelative(virtualDir), physicalDir);

            return(h.Unwrap());
        }
        public static object CreateApplicationHost(Type hostType, string virtualDir, string physicalDir)
        {
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                throw new PlatformNotSupportedException(System.Web.SR.GetString("RequiresNT"));
            }
            if (!StringUtil.StringEndsWith(physicalDir, Path.DirectorySeparatorChar))
            {
                physicalDir = physicalDir + Path.DirectorySeparatorChar;
            }
            ApplicationManager applicationManager = ApplicationManager.GetApplicationManager();
            string             appId = (virtualDir + physicalDir).GetHashCode().ToString("x");

            return(applicationManager.CreateInstanceInNewWorkerAppDomain(hostType, appId, VirtualPath.CreateNonRelative(virtualDir), physicalDir).Unwrap());
        }