views:

3207

answers:

4

Hi, I have code that uses Microsoft.SqlServer.Management.Smo. (Built in Visual Studio 2005 SP1) It works fine on SQL 2000 & SQL 2005 machine. But when it is run on SQL 2008 machine it throws an exception:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.Smo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.SqlServer.Smo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'

=== LOG: This bind starts in default load context. LOG: No application configuration file found. LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config. LOG: Post-policy reference: Microsoft.SqlServer.Smo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 LOG: Attempting download of new URL file:///C:/Documents and Settings/Automation/Desktop/Debug/Microsoft.SqlServer.Smo.DLL. LOG: Attempting download of new URL file:///C:/Documents and Settings/Automation/Desktop/Debug/Microsoft.SqlServer.Smo/Microsoft.SqlServer.Smo.DLL. LOG: Attempting download of new URL file:///C:/Documents and Settings/Automation/Desktop/Debug/Microsoft.SqlServer.Smo.EXE. LOG: Attempting download of new URL file:///C:/Documents and Settings/Automation/Desktop/Debug/Microsoft.SqlServer.Smo/Microsoft.SqlServer.Smo.EXE.

I have installed SQL 2005 Backwards compatibility pack (updated for SQL 2008) & SQL management Objects(Updated for SQL 2008)

Any suggestions.

i went through http://stackoverflow.com/questions/537613/sql-server-smo-complains-of-missing-dll but not much of a help.

A: 

Take a look at the "Microsoft SQL Server 2008 Management Objects" section of Microsoft SQL Server 2008 Feature Pack, April 2009 (make sure you have SQL Server 2008 Service Pack 1 installed)

Mitch Wheat
Ganesh R.
+1  A: 

Hi.

I found the issue. I was building the project with references to SQL 2005 SDK DLLs. I removed all the references & added the references again (now pointing to SQL 2008 dlls view post: http://msdn.microsoft.com/en-us/library/ms162129.aspx) for list of references to add. Additionally, the target machine needs to have Microsoft SQL Server 2005 Backward Compatibility Components & Microsoft SQL Server 2008 Management Objects & SQL Server System CLR Types (2008) installed.

Ganesh R.
A: 

me too get same error

dfg
A: 

Not sure if this was resolved, but it sounds like the original poster had the "Specific Version" property set to "True" for the dll.

To fix this, select the reference in the References folder and set the "Specific Version" property to true.

Microsoft did move some functionality to Microsoft.SMO.Extended, but that's a separate issue

justincredulous
Even if I changed the property "Specific Version" to false, it did not work. This was because in my case, I was trying to run an application built with reference to v9 dlls on a machine with v10 dlls.
Ganesh R.
Ah, I see. We just encountered this problem as well. As a a workaround, we copied most of the DLLs from the ..\Microsoft SQL Server\90\SDK\Assemblies directory directly into the bin directory of our project. The app will look in the bin directory for the references (instead of the GAC since it won't exist in the GAC in the target computer)
justincredulous

related questions