I am using .net framework 4.0 and working on Web deployment Setup, I have referenced the SMO Assemblies of sql server 2008, and When I Call ExecuteNonQuery Function in my setup using Smo Assemblies it gives me this error "Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information." but sometimes it works correctly in my code but some time it gives this error,
I have using the same class, same method sometimes its run correctly and some time it gives this error, I am completely fade up with this error, I couldn't find any reason for that and I also want to know is SMO assemblies are available in .Net framework v4.0?
From: http://social.msdn.microsoft.com/Forums/en-US/sqlsmoanddmo/thread/533f7044-1109-4b7a-a697-2621f23017d6
This is a known issue. SMO's usage against .Net 4.0 hasnt been signed off or announced by microsoft.
There is an unsupported option to get this working (add this to your app.config):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Why are you using "SMO assemblies" to call ExecuteNonQuery?
Why not just reference and use ADO.NET? See System.Data.SqlClient.ExecuteNonQuery(...)
The real answer for using SMO in .NET v4 right now seems to be here in the workaround:
http://connect.microsoft.com/SQLServer/feedback/details/643811/net-4-0-compatible-smo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With