views:

570

answers:

1

Prepared a manged c# DLL using assemblies of SMO of version:10.0.0.0 of SQL 2008 and I called the functions in this DLL from an unmanged c++ code. This application is running successfully for SQL Server 2008 but this application is throwing exception when i run for SQL Server 2005 as follows:

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

What would be the reason?
Is it failing in sql 2005 because of the version mismacth of SMO?
How can I give support to sql 2005 and sql2008 in my application using a single C# dll?

+1  A: 

I faced the same issue before, are you running this application from the same machine where you have 2008 and 2005 installed?

If not I suggest you install the SMO libraries for Sql 2008 on the machine/client on which you are running the assembly.

This download will give you the libraries

Binoj Antony
The application is built in the machine having sql 2008 and iam running this application in another machine having sql2005. I will install this download and update you the result. Thanks
After instaling SMO 2008 the application ran successfully in the machine having sql 2005. But cant we prepare an application that uses SMO - supporting both sql2005 and sql2008??
Your application `does` support both 2005 and 2008, but since the application you have built has a reference to the assembly of Sql 2008 you just need to have the 2008 library installed on the `client` machine only.
Binoj Antony
Why the above exception is seen though smo.dll is available for sql 2005?Is there any possibilty to support sql 2005 also without installing SMO of SQL 2008? Do I need to add assemblies of both sql 2005 and 2008 SMOs while preparing build ?If I prepare build using SMO of sql 2005 will that support in sql2008? I read in msdn forums that it will fail?
On a machine on which sql 2005 is installed the smo assembly will give you access to only 2005 sql specific functionality.And of course it will fail(2005 smo support for 2008). Smo like any other .NET assembly is only backward compatible not forward, smo for 2005 will not support 2008, but Smo of 2008 will work for 2005.If you do not want to install the Sql 2008 Smo library on the 2005 specific client then one option is to make two separate builds. One for 2005 and one for 2008.
Binoj Antony