Uruchom plik .sql z aplikacji w języku C # za pomocą biblioteki SMO

Buduję aplikację w C # visual studio 2012 RC.

Muszę uruchomić skrypty w aplikacji. do tego używam. Te dwie biblioteki. Docelowa platforma .net mojego programu to 4.5.

using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;

Napisałem kod, aby uruchomić skrypty po sprawdzeniu, czy istnieje baza danych pogody.

Po uruchomieniu kodu pojawia się nieoczekiwany wyjątek. Naprawdę wiem, co to znaczy. Czy możesz mi pomóc, aby pozbyć się tego wyjątku.

Dołączam także mój kod i podgląd wyjątków.

Proszę, pomóżcie mi ... Już za dużo googlałem.

**Here are the Exception Details.**

System.IO.FileLoadException był nieobsługiwany HResult = -2146232799 Wiadomość = Montaż w trybie mieszanym jest zbudowany w stosunku do wersji „v2.0.50727” środowiska wykonawczego i nie można go załadować w środowisku wykonawczym 4.0 bez dodatkowych informacji o konfiguracji. Source = mscorlib StackTrace: at System.Reflection.RuntimeAssembly.GetType (RuntimeAssembly Assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) w System.Reflection.RuntimeAssembly.GetType (String name, Boolean throwOnError, Boolean ignoreCase) w System. Reflection.Assembly.GetType (String name, Boolean throwOnError) w Microsoft.SqlServer.Management.Common.ServerConnection.GetStatements (String query, ExecutionTypes executionType, Int32 & statementToReverse) w Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery (String sqlCommand, ExecutionTypes executionType) w Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery (String sqlCommand) w McFarlaneIndustriesPOSnamespace.SplashScreen.CreateDatabase () w e: Works McFarlane Industries McFarlane Industries Point of Sale Kod źródłowy McFarlaneIndustries SplashScreen.cs: linia 139 w McFarlaneIndustriesPOSnamespace.SplashScreen.splashScreenTimer_Tick (Nadawca obiektów, EventArgs e ) e: Prace McFarlane Industries Kod źródłowy McFarlane Industries Point of Sale McFarlaneIndustries SplashScreen.cs: linia 159 w System.Windows.Forms.Timer.OnTick (EventArgs e) w System.Windows.Forms.Timer.TimerNativeWindow .WndProc (Message & m) w System.Windows.Forms.NativeWindow.DebuggableCallback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) w System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW (MSG i msg) w System.Windows.Forms. Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop (IntPtr dwComponentID, powód Int32, Int32 pvLoopData) w System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner (powód Int32, kontekst ApplicationContext) w System.Windows.Forms .Application.ThreadContext.RunMessageLoop (powód Int32, kontekst ApplicationContext) w System.Windows.Forms.Application.Run (Form mainForm) w McFarlaneIndustriesPOSnamespace.Program.Main () in e: Works McFarlane Industries McFarlane Industries Point of S ale Kod źródłowy McFarlaneIndustries Program. .Run (Boolean checkAptModel) w System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly () w System.Runtime.Hosting.ApplicationActivator.CreateInstance (ActivationContext activationContext, String [] activationCustomData) w System.Runtime.Hosting.ApplicationActivator.CreateInstance (ActivContextActivator.CreateInstance) ) w System.Activator.CreateInstance (ActivationContext activationContext) w Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone () w System.Threading.ThreadHelper.ThreadStart_Context (Object state) w System.Threading.ExecutionContext.RunInternal (ExecutionContext executionContext, Callback ContextCallback, Stan obiektu, Boolean preserveSyncCtx) w System.Threading.ExecutionContext.Run (ExecutionContext exec utionContext, Callback ContextCallback, Stan obiektu, Boolean preserveSyncCtx) w System.Threading.ExecutionContext.Run (ExecutionContext executionContext, Callback ContextCallback, Stan obiektu) w System.Threading.ThreadHelper.ThreadStart () InnerException:

questionAnswers(1)

yourAnswerToTheQuestion