Click here to Skip to main content
14,298,783 members
Rate this:
Please Sign up or sign in to vote.
See more:
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."


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?
Posted
Updated 28-Jul-19 5:22am
v2
Comments
Rate this:
Please Sign up or sign in to vote.

Solution 1

Please check this link problem might difference in version sql server in laptop and PC
Backward Compatibility in SMO - SQL Server | Microsoft Docs[^][^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

You can get the dll by installing the SMO nuget Packages
Please check this link problem might difference in version sql server in laptop and PC
Backward Compatibility in SMO - SQL Server | Microsoft Docs[^][^]
   
Comments
Member 11298827 27-Jul-19 12:26pm
   
Thanks for your reply - I don't have any experience with Nuget - so after reading about it, I found that it is built into VS2015. I used it to look at the various packages but did not see "microsoft.sqlserver.sqlmanagementobjects" (as seen on Nuget site).
I did see "Bundle.Microsoft.SqlServer.SMO". It is version 12.0.2000, updated 9 months ago. Is that the one I should use?
BillWoodruff 27-Jul-19 15:27pm
   
Please do not post two solutions: edit the first solution.
Member 11298827 27-Jul-19 15:54pm
   
Update - I tried using "Bundle.Microsoft.SqlServer.SMO" from Nuget, but it made matters even worse - When I install the app on the development PC and try to restore, an exception is thrown - Method not found: 'Void Microsoft.SqlServer.Management.Smo.BackupDeviceItem...
So it would seem the Backup and Restore methods are not in the newer DLL?

One more question - can SQL Server 2016 Express be safely installed over previous versions? I don't want to start uninstalling older versions if I can avoid it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100