標籤:system.badimageforma 未能負載檔案或程式集 oracle.dataaccess 依賴項 格式不正確
本機環境:Win7 32位,開發工具:vs2008
今天更新webservices的時候,如:
報出了下面的錯誤:
在服務端開啟asmx檔案時,錯誤資訊如下:
“/”應用程式中的伺服器錯誤。未能負載檔案或程式集“Oracle.DataAccess”或它的某一個依賴項。試圖載入格式不正確的程式。說明: 執行當前 Web 請求期間,出現未處理的異常。請檢查堆疊追蹤資訊,以瞭解有關該錯誤以及代碼中導致錯誤的出處的詳細資料。 異常詳細資料: System.BadImageFormatException: 未能負載檔案或程式集“Oracle.DataAccess”或它的某一個依賴項。試圖載入格式不正確的程式。源錯誤: 執行當前 Web 請求期間產生了未處理的異常。可以使用下面的異常堆疊追蹤資訊確定有關異常原因和發生位置的資訊。程式集載入跟蹤: 下列資訊有助於確定程式集“Oracle.DataAccess”無法載入的原因。警告: 程式集綁定日誌記錄被關閉。要啟用程式集綁定失敗日誌記錄,請將註冊表值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD)設定為 1。注意: 會有一些與程式集綁定失敗日誌記錄關聯的效能損失。要關閉此功能,請移除註冊表值 [HKLM\Software\Microsoft\Fusion!EnableLog]。堆疊追蹤: [BadImageFormatException: 未能負載檔案或程式集“Oracle.DataAccess”或它的某一個依賴項。試圖載入格式不正確的程式。] System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0 System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43 System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127 System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142 System.Reflection.Assembly.Load(String assemblyString) +28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46[ConfigurationErrorsException: 未能負載檔案或程式集“Oracle.DataAccess”或它的某一個依賴項。試圖載入格式不正確的程式。] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178 System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163 System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53 System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175 System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +86 System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261 System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101 System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +83 System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath) +10 System.Web.UI.WebServiceParser.GetCompiledType(String inputFile, HttpContext context) +43 System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +180 System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47 System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +193 System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155版本資訊: Microsoft .NET Framework 版本:2.0.50727.5477; ASP.NET 版本:2.0.50727.5483 <span style="font-family: 宋體; background-color: rgb(255, 255, 255);"> </span>
原因:
代碼中的Oracle.DataAccess版本與本機安裝Oracle版本(服務端或者用戶端)的版本不一樣,例如:這個代碼中用到的版本是:10,而我本機安裝的是11。雖然用戶端與服務的引用中都沒有用到Oracle.DataAccess,但在ZJGL_PublicServer這個工程中用到了這個dll,如:
解決辦法:
在ZJGL_PublicServer這個工程中移除Oracle.DataAccess這個引用,替換成本機版本的dll(在安裝目錄下搜尋Oracle.DataAccess.dll),搞定。