views:

3586

answers:

3

I have a small app which references the Microsoft.SqlServer.Smo assembly (so I can display to the user a list of servers & databases to which they can connect).

My application originally referenced Microsoft.SqlServer.Smo and Microsoft.SqlServer.ConnectionInfo. Things worked as expected on my dev box.

When I installed the application on a test machine, I received a System.IO.FileNotFoundException. The details of the message included the following: Could not load file or assembly Microsoft.SqlServer.SmoEnum

I eventually resolved the issue by referencing the following assemblies in addition to the ones mentioned above:

  • Microsoft.SqlServer.SmoEnum
  • Microsoft.SqlServer.SqlEnum
  • Microsoft.SqlServer.BatchParser
  • Microsoft.SqlServer.Replication

Can anyone confirm that I do indeed need to include each of these additional assemblies in my application (and therefore install them on user's machines) even though the app builds fine on my development box without them referenced?

A: 

Since JIT links to external assemblies at run-time, this question can't be answered without analyzing your code and seeing what you call and in turn, what those calls call, etc.

If you want to analyze this yourself, your best bet would be to reference only the assembly you need and then to learn from the exceptions and inner-exceptions what happened.

Another thing you should look into is why the four assemblies you mention aren't in the GAC. It sure seems like they should be.

Omer van Kloeten
+1  A: 

Yes, they do need to be included. On the development machine you probably have SQL Server installed, which places those assemblies into the Global Assembly Cache. Whenever you build, Visual Studio just pulls from them from the GAC. It also assumes that the GAC of whatever computer it will be deployed on will also have those files. If not, it throws the FileNotFound exception.

David Sokol
+2  A: 

Here you can find what you need

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=50b97994-8453-4998-8226-fa42ec403d17

yeradis
Nij