0

我正在尝试使用 Microsoft.Web.Administration dll 在 IIS7 中创建单独的工作流实例作为应用程序。当它尝试将应用程序添加到站点 ApplicationsCollection 时,我收到一个 COM 错误:“无效的应用程序路径\r\n”

using (ServerManager manager = new ServerManager())
            {
                var site = manager.Sites.Where(x => x.Name == Properties.Settings.Default.WorkflowWebsiteName).Single();

                StringBuilder stringBuilder = new StringBuilder()
                    .Append(m_workflowDefinition.AccountId)
                    .Append("/")
                    .Append(m_workflowDefinition.WorkflowDefinitionId)
                    .Append("/")
                    .Append(m_workflowDefinition.Version)
                    .Append("/");

                string virtualPath = stringBuilder.ToString();
                string physicalPath = Properties.Settings.Default.ApplicationPoolString +
                                      virtualPath.Replace("/", "\\");

                if (!Directory.Exists(physicalPath)) Directory.CreateDirectory(physicalPath);

                //Create the workflow service definition file
                using (StreamWriter writer = new StreamWriter(Path.Combine(physicalPath, m_workflowDefinition.WorkflowName + WORKFLOW_FILE_EXTENSION)))
                {
                    writer.Write(m_workflowDefinition.Definition);
                }

                //Copy dependencies                    
                string dependencyPath = m_workflowDefinition.DependenciesPath;
                CopyAll(new DirectoryInfo(dependencyPath), new DirectoryInfo(physicalPath));

                //Create a new IIS application for the workflow   
                var apps = site.Applications.Where(x => x.Path == virtualPath);
                if (apps.Count() > 0)
                {
                    site.Applications.Remove(apps.Single());
                }
                Application app = site.Applications.Add(virtualPath, physicalPath);

                app.ApplicationPoolName = "Workflow AppPool";
                app.EnabledProtocols = PROTOCOLS;

                manager.CommitChanges();
            }

分配给 virtualPath 的值类似于:“something/something/something”,而对于 physicalPath,它是“c:\inetpub\wwwroot\Workflow\something\something\something”。有任何想法吗?

任何帮助是极大的赞赏。

4

1 回答 1

1

尝试将“某事/某事/某事”路径更改为“/某事/某事/某事”。IIS 管理调用需要路径开头的额外斜杠。

于 2010-04-13T14:22:12.780 回答