我正在 C# Visual Studio 2012 RC 中构建一个应用程序。
我必须在应用程序中运行脚本。为此我正在使用。这两个库。我的应用程序的目标 .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 运行时中加载。Source=mscorlib StackTrace:在 System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) 在 System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly 程序集,字符串名称,布尔 throwOnError,布尔忽略Case,ObjectHandleOnStack 类型)。 Microsoft.SqlServer.Management.Common.ServerConnection.GetStatements(String query, ExecutionTypes executionType, Int32& statementsToReverse) 在 Microsoft.SqlServer.Management.Common.ServerConnection 的 Reflection.Assembly.GetType(String name, Boolean throwOnError)。