2012-06-06 94 views
15

我找不到爲什麼我在運行我的應用程序(MVC 3)時遇到此錯誤。該項目引用了Microsoft.SQLServer.ManagedDTS。我安裝了SQL Server 2008 R2和SQL Server 2012(均爲Express)。我正在使用此應用程序的2012年。無法加載文件或程序集'Microsoft.SqlServer.DTSRuntimeWrap'

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.

源錯誤:

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].

堆棧跟蹤:

[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

回答

0

的Microsoft.SqlServer.DTSRuntimeWrap.dll可能不是在GAC,這意味着它必須被複制在您的Web應用程序的bin文件夾中或手動添加到您計算機的GAC(例如,使用GACUTIL.exe)。你可以在C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\中找到它。如果您從Visual Studio項目中的位置引用它,那麼您可以在複製本地的參考的屬性中設置該選項。

請注意,此DLL可能不是可再發行的,因此您可能必須在運行該應用程序的任何Web服務器上實際安裝SSIS,以便不違反SSIS許可,但您必須驗證該內容。

+1

也爲後人:@ schellack的評論在這裏關於授權是現貨。如果安裝SSIS(服務器許可證)或BIDS(客戶端許可證),則會安裝「運行時」DTS位。因此,AFAIK *無論是哪種方式都有許可含義。 – piers7

34

如果這是Web應用程序的一部分,則需要從IIS的應用程序池啓用運行32位應用程序。這將解決您的問題。

+1

我知道這是一箇舊帖子,但僅供參考:這個答案是正確的只是因爲堆棧跟蹤中的底層「BadImageFormatException」 - 還有很多其他方法可以獲得標題錯誤。 – piers7

+2

一些更多的幫助: 轉到IIS>應用程序池>選擇相關池> Rigth單擊並選擇高級設置..>更改「啓用32位應用程序」 –

相關問題