私はC#visual studio 2012 RCでアプリケーションを構築しています。SMOライブラリを使用してC#でアプリケーションから.sqlファイルを実行
私はアプリケーション内でスクリプトを実行する必要があります。これは私が使用しているためです。 これらの2つのライブラリ。 私のアプリケーションのターゲット.netフレームワークは4.5です。
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
気象データベースが存在するかどうかを確認した後にスクリプトを実行するコードを記述しました。
私はコードを実行すると、予期しない例外がポップアップします。私は本当にそれが何を意味するのか知っています。この例外を取り除くために私を助けてください。
私のコードと例外のプレビューも添付しています。
私を助けてください...私はすでにあまりにも多くのグーグルグーグルをしています。
**Here are the Exception Details.**
System.IO.FileLoadExceptionは HRESULT = -2146232799 メッセージ=混合モードアセンブリは、ランタイムのバージョン「v2.0.50727の」に対して構築されており、4.0ランタイムでロードすることはできませんでした未処理追加の構成情報は必要ありません。 ソース= mscorlib のStackTrace:System.Reflection.RuntimeAssembly.GetTypeでSystem.Reflection.RuntimeAssembly.GetTypeで (RuntimeAssembly組立、文字列の名前、ブールthrowOnError、ブールignoreCaseは、ObjectHandleOnStackタイプ) (文字列名、ブールthrowOnError、ブールignoreCaseは)Microsoft.SqlServer.Management.Common.ServerConnection.GetStatementsでSystem.Reflection.Assembly.GetType(文字列名、ブールthrowOnError) (文字列のクエリ、ExecutionTypes executionType、のInt32 & statementsToReverse) で Microsoft.SqlServer.Management.Commonで.ServerConnection.ExecuteNonQuery(String sqlCommand、ExecutionTypes executionType) at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCo mmand) McFarlaneIndustriesPOSnamespace.SplashScreen.CreateDatabaseで()E中:販売のソースコード\ McFarlaneIndustries \ SplashScreen.csの作品\マクファーレン産業\マクファーレン産業ポイント\:McFarlaneIndustriesPOSnamespace.SplashScreen.splashScreenTimer_Tick(オブジェクト送信者、EventArgsの電子)のライン139 System.Windows.Forms.Timer.OnTick(EventArgs e) (System.Windows.Forms.Timer)の行159 にある行:\ Works \ McFarlane Industries \ McFarlane Industriesの販売店コードTimerNativeWindow.WndProc System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG & MSG)でSystem.Windows.Forms.NativeWindow.DebuggableCallbackで(メッセージ& M) (のIntPtr hWndは、MSGのInt32、のIntPtr WPARAM、LPARAMのIntPtr) System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(のInt32理由でSystem.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(のIntPtr dwComponentID、のInt32理由、のInt32 pvLoopData) で、 ApplicationContextコンテキスト) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason、ApplicationContext context) at System.Windows.Forms.Application.Run(フォームmainForm) at McFarlaneIndustriesPOSnamespace.Program.Main()in e: \ Works \ McFarlane Industries \ McFarlane Industries Point of Saleソースコード\ McFarlaneIndustries \ Program.cs:Line 19 at System.AppDomain。_nExecuteAssembly(RuntimeAssemblyアセンブリ、文字列[]引数)System.AppDomain.nExecuteAssemblyで (RuntimeAssemblyアセンブリ、文字列[]引数)System.Runtime.Hosting.ManifestRunner.Run(ブールcheckAptModel)で System.Runtime.Hosting.ManifestRunnerでSystem.Runtime.Hosting.ApplicationActivator.CreateInstanceで.ExecuteAsAssembly() (activationContext activationContext、文字列[] activationCustomData)System.Activator.CreateInstanceでSystem.Runtime.Hosting.ApplicationActivator.CreateInstance(activationContext activationContext) で(activationContext activationContext) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() at System.Threading.ThreadHelper.ThreadStart_Context(オブジェクト状態)System.Threading.ExecutionContext.Run(ExecutionContext executionContext、ContextCallbackコールバック、オブジェクト状態、ブールpreserveSyncCtx)の のSystem.Threading.ExecutionContext.RunInternal(ExecutionContext実行コンテキスト、ContextCallbackコールバック、オブジェクト状態、ブールpreserveSyncCtx) System.Threading時の System.Threading.ThreadHelper.ThreadStartでExecutionContext.Run(のExecutionContextのExecutionContext、ContextCallbackコールバック、オブジェクトの状態) () のInnerException:
例外の詳細を投稿してください – saille
私は質問を編集し、あなたが求めたように例外の詳細を追加しました。スナップショットは、例外がポップアップするポイントを示します。詳細とスナップショットもご覧ください。 –