【解決方法】アプリケーションが DLL ファイルを見つけることができません


I have a Windows Form project in VS2015. It uses System.Data.SqlClient to access a local database file - MyDB.mdf. I have SQL Server 2014 installed, including "Express LocalDB". Targeting .Net Framework 4.0.

The application uses four DLL files to support Backup and Restore functions:

Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.Management.Sdk.Sfc.dll
Microsoft.SqlServer.Smo.dll
Microsoft.SqlServer.SmoExtended.dll

These DLLs are included in the project References.

All works properly on my development PC (Windows 10), but when I install the application on my Windows 10 laptop, there is a problem  - When I do backup or restore, an exception is thrown - 

"Could not load file or assembly 'Microsoft.SqlServer.Smo,
Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc19'
or one of its dependencies. The system cannot find the file specified."

私が試したこと:

I have tried including all the DLL files in the application folder, and also in a sub-folder "lib", but for some reason the DLL file cannot be found.     Note: SQL Server 2016 Express is installed on the laptop.

Question: How do I get the application to find the DLL file(s)? 

7/28 更新 – SQL Server 2016 Express を開発用 PC にインストールし、VS2015 プロジェクトの参照セクションを適切な DLL インスタンスに更新しました。 これらの DLL インスタンスがラップトップ ターゲット PC 上に存在することを確認しました (同じ日付と時刻)。 開発用 PC でアプリケーションをビルドし、ラップトップにインストールすると、すべてが機能します。
注: Setup.exe ファイルの作成には Inno Setup を使用しています。
質問: セットアップに DLL ファイルをパッケージ化して、別のマシンにインストールするときにそれらの DLL が使用されるようにする方法はありますか?

解決策 1

このリンクを確認してください。ラップトップと PC の SQL サーバーのバージョンに問題がある可能性があります。
SMO の下位互換性 – SQL Server | Microsoft ドキュメント[^][^]

解決策 2

SMO nuget パッケージをインストールすることで dll を入手できます
このリンクを確認してください。ラップトップと PC の SQL サーバーのバージョンに問題がある可能性があります。
SMO の下位互換性 – SQL Server | Microsoft ドキュメント[^][^]

コメント

タイトルとURLをコピーしました