20

I can't figure out why I'm getting this error when I run my application (MVC 3). The project has a reference to Microsoft.SQLServer.ManagedDTS. I have both SQL Server 2008 R2 and SQL Server 2012 (both Express) installed. I'm using 2012 with this application.

Server Error in '/' Application.

Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.SqlServer.DTSRuntimeWrap' could not be loaded.

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:

[BadImageFormatException: Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
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, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192 System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +123

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
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): Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700896 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869125

4

3 回答 3

44

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

于 2012-10-27T20:30:47.137 回答
1

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

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

于 2012-06-06T16:31:38.107 回答
0

在我的情况下,在 IIS 中的“DefaultAppPool”上启用“允许 32 位应用程序”后,问题就解决了。

以下是执行此操作的步骤

  1. 开放互联网信息服务
  2. 转到应用程序池
  3. 右键点击“DefaultAppPool”</li>
  4. 选择高级设置
  5. 将“启用 32 个应用程序”设置为 true
  6. 点击确定
  7. 回收应用程序池
  8. 重新启动 IIS
于 2021-06-26T14:40:07.707 回答