如何使用 C# 恢复 IIS 元数据库备份
我发现 Stack Overflow 问题描述了如何在 C# 中备份 IIS Metabase 这里,我已经成功地使用引用的代码此处。但是,我在使用 C# 代码恢复这些备份(或者实际上在 IIS 中手动创建的任何备份)时遇到困难。
有谁知道如何做到这一点,或者是否可以做到?与备份本身不同,我在网上找不到任何这样的示例。
我已尝试以下代码,但收到错误'调用的目标已抛出异常'
using (DirectoryEntry localhostIIS = new DirectoryEntry("IIS://LocalHost"))
{
localhostIIS.Invoke("Restore", new object[] { string.Empty, 0, 0});
}
现在,虽然我确定我正在使用错误的名称和/或调用该方法对象结构,我一直无法在任何地方找到调用它的正确方式......
任何人都可以指出我正确的方向吗?
I've found the Stack Overflow question describing how to backup the IIS Metabase in C# here, and I have been successful at getting that to work using the code referenced here. However, I am having difficulty restoring those backups (or indeed any backups created manually in IIS) using C# code.
Does anyone know how to do this, or even if it can be done? I haven't been able to find any examples of this on the web, unlike the backup itself.
I have tried the following code, but receive the error 'Exception has been thrown by the target of an invocation'
using (DirectoryEntry localhostIIS = new DirectoryEntry("IIS://LocalHost"))
{
localhostIIS.Invoke("Restore", new object[] { string.Empty, 0, 0});
}
Now while I'm sure that I'm calling the method with the wrong name and/or object structure, I haven't been able to find the correct way of calling it anywhere....
Can anybody please point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试使用命名备份进行此操作,并通过一些调整使其正常工作:
I tried this with a named backup and got this to work with some tweaks: