无法加载文件或程序集"Microsoft.SqlServer.DTSRuntimeWrap"

Mar*_*sel 17 sql-server asp.net

当我运行我的应用程序(MVC 3)时,我无法弄清楚为什么我会收到此错误.该项目引用了Microsoft.SQLServer.ManagedDTS.我安装了SQL Server 2008 R2和SQL Server 2012(均为Express).我正在使用2012这个应用程序.

'/'应用程序中的服务器错误.

无法加载文件或程序集"Microsoft.SqlServer.DTSRuntimeWrap"或其依赖项之一.尝试加载格式不正确的程序.

描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.

异常详细信息:System.BadImageFormatException:无法加载文件或程序集"Microsoft.SqlServer.DTSRuntimeWrap"或其依赖项之一.尝试加载格式不正确的程序.

来源错误:

在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.

程序集加载跟踪:以下信息有助于确定无法加载程序集"Microsoft.SqlServer.DTSRuntimeWrap"的原因.

警告:装配绑定日志记录已关闭.要启用程序集绑定失败日志记录,请将注册表值[HKLM\Software\Microsoft\Fusion!EnableLog](DWORD)设置为1.注意:程序集绑定失败日志记录会导致一些性能损失.要关闭此功能,请删除注册表值[HKLM\Software\Microsoft\Fusion!EnableLog].

堆栈跟踪:

[BadImageFormatException:无法加载文件或程序集'Microsoft.SqlServer.DTSRuntimeWrap'或其依赖项之一.尝试加载格式不正确的程序.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+0
System. Reflection.RuntimeAssembly.InternalLoadAssemblyName(的AssemblyName assemblyRef,证据assemblySecurity,StackCrawlMark&stackMark,布尔forIntrospection,布尔suppressSecurityChecks)567
System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString,证据assemblySecurity,StackCrawlMark&stackMark,布尔forIntrospection)192 System.Reflection.Assembly .Load(String assemblyString)+35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+123

[ConfigurationErrorsException:无法加载文件或程序集'Microsoft.SqlServer.DTSRuntimeWrap'或其依赖项之一.尝试加载格式不正确的程序.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+11568160
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+485 System.Web.Configuration .AssemblyInfo.get_AssemblyInternal()+ 79 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)+337
System.Web.Compilation.BuildManager.CallPreStartInitMethods()+280
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException)+1167

[HttpException(0x80004005):无法加载文件或程序集"Microsoft.SqlServer.DTSRuntimeWrap"或其依赖项之一.尝试加载格式不正确的程序.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+11700896 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)+141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr ,HttpContext context)+4869125

Far*_*hid 37

如果这是Web应用程序的一部分,则需要从IIS的应用程序池中启用运行32位应用程序.这将解决您的问题.

  • 更多帮助:转到IIS>应用程序池>选择相关池> Rigth单击并选择高级设置..>更改"启用32位应用程序" (5认同)
  • 我知道这是一篇旧帖子,但仅供参考:这个答案是正确的,因为堆栈跟踪中存在潜在的“BadImageFormatException”——还有很多其他方法可以获得标题错误。 (2认同)

sch*_*ack 2

Microsoft.SqlServer.DTSRuntimeWrap.dll 可能不在GAC中,这意味着必须将其复制到 Web 应用程序的bin文件夹中或手动添加到计算机的 GAC 中(例如,使用 GACUTIL.exe)。您或许可以在 中找到它C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\如果您从 Visual Studio 项目中的类似位置引用它,那么您可能只需将“复制本地”引用的属性中的选项设置为True

请注意,此 DLL 可能不可重新分发,因此您可能必须在运行该应用程序的任何 Web 服务器上实际安装 SSIS,以免违反 SSIS 许可,但您必须验证这一点。