手动创建应用程序池,并自动将程序assign到新创建的池中(MSI制作)
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-05-20
ldren; 77 DirectoryEntry newVDir = vdirs.Add(vDirName, (className.Replace ("Service", "VirtualDir"))); 78 newVDir.Properties["Path"][0] = physicalPath; 79 newVDir.Properties["AccessScript"][0] = true; 80 // These properties are necessary for an application to be created. 81 newVDir.Properties["AppFriendlyName"][0] = vDirName; 82 newVDir.Properties["AppIsolated"][0] = "1"; 83 newVDir.Properties["AppRoot"][0] = "/LM" + metabasePath.Substring (metabasePath.IndexOf("/", ("IIS://".Length))); 84 85 newVDir.CommitChanges(); 86 87 Console.WriteLine(" Done."); 88 } 89 else 90 Console.WriteLine(" Failed. A virtual directory can only be created in a site or virtual directory node."); 91 } 92 catch (Exception ex) 93 { 94 Console.WriteLine("Failed in CreateVDir with the following exception: \n{0}", ex.Message); 95 } 96 } 97 98 99 100 static void AssignVDirToAppPool(string metabasePath, string appPoolName) 101 { 102 // metabasePath is of the form "IIS://<servername>/W3SVC/<siteID>/Root[/<vDir>]" 103 // for example "IIS://localhost/W3SVC/1/Root/MyVDir" 104 // appPoolName is of the form "<name>", for example, "MyAppPool" 105 Console.WriteLine("\nAssigning application {0} to the application pool named {1}:", metabasePath, appPoolName); 106 107 try 108 { 109 DirectoryEntry vDir = new DirectoryEntry(metabasePath); 110 string className = vDir.SchemaClassName.ToString(); 111 if (className.EndsWith("VirtualDir")) 112 { 113 object[] param = { 0, appPoolName, true }; 114 vDir.Invoke("AppCreate3", param); 115 vDir.Properties["AppIsolated"][0] = "2"; 116 Console.WriteLine(" Done."); 117 } 118 else 119 Console.WriteLine(" Failed in AssignVDirToAppPool; only virtual directories can be assigned to application pools"); 120 } 121 catch (Exception ex) 122 { 123 Console.WriteLine("Failed in AssignVDirToAppPool with the following exception: \n{0}", ex.Message); 124 } 125 } 126 127 128 129 } 130 } 131 132 133 出处:http://mqsuper.cnblogs.co |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于手动创建应用程序池,并自动将程序assign到新创建的池中(MSI制作)的所有评论