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:
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=126.96.36.199, Culture=neutral, PublicKeyToken=89845dcd8080cc19'
or one of its dependencies. The system cannot find the file specified."
What I have tried:
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 Update - I installed SQL Server 2016 Express on my development PC, and then updated the references section in the VS2015 project to the appropriate DLL instances. I verified these DLL instances were present on the laptop target PC (same date and time). Now when I build the application on the development PC, and install it on the laptop, everything works.
Note: I'm using Inno Setup to make the setup.exe file.
Question: Is there a way to package the DLL files in my setup so when it is installed on another machine, those DLLs are used?