为什么无法找到Microsoft.SqlServer.Management.Smo.Restore

问题描述:

在我查看代码项目中的教程在应用程序部署期间还原数据库之后[ ^ ]



i已经引用了Microsoft.SqlServer.Management.Smo.dll并声明了命名空间



但是以下内容代码显示错误类型或命名空间名称'无法找到'恢复'



after i looked the tutorial in code project Restore Database during Application Deployment[^]

i have already make referenced to Microsoft.SqlServer.Management.Smo.dll and declare namespace

but the following code shows the error type or namespace name 'Restore' could not be found

Restore sqlRestore = new Restore();

            BackupDeviceItem deviceItem = new BackupDeviceItem(filePath, DeviceType.File);
            sqlRestore.Devices.Add(deviceItem);
            sqlRestore.Database = databaseName;





如何解决此错误



how to solve this error

请参阅此 *答案 [ ^ ]。



似乎您需要添加更多参考资料才能正常工作。
See this * answer[^].

Seems you need to add some more references for it to work.


右键单击在项目上,打开引用并再次检查是否有感叹号。

在这种情况下,找不到dll或者可能存在.Net框架版本不匹配。
Right click on project, open references and check if there is an exclamation mark again this dll.
In this case, either the dll is not found or maybe there is a .Net framework version mismatch.