2011-10-11 74 views
1

我收到一個令我困惑的錯誤。我有一個.NET應用程序,它引用了一個用於自動化第三方程序的OCX文件。當我從Visual Studio中運行它時,這些應用程序完美運行,但是當我將它打包到MSI文件並將其安裝到測試機器上時,它會失敗地顯示「無法加載文件或程序集」Interop.OISSERVERLib,...「。無法加載文件或程序集(.NET,Visual Studio 2010)

有沒有人對我怎樣才能解決這個問題有什麼建議

System.InvalidOperationException was unhandled 
Message=An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'Interop.OISSERVERLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. 
Source=SLSClaimantWorkbook 
StackTrace: 
    at SLSClaimantWorkbook.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190 
    at SLSClaimantWorkbook.My.MyProject.MyForms.get_SLSClaimantWorkbook() 
    at SLSClaimantWorkbook.My.MyApplication.OnCreateMainForm() in C:\Documents and Settings\C15919\My Documents\Visual Studio 2005\Claimant Workbook\Claimant Workbook\My Project\Application.Designer.vb:line 35 
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() 
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() 
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) 
    at SLSClaimantWorkbook.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 
InnerException: System.IO.FileNotFoundException 
    Message=Could not load file or assembly 'Interop.OISSERVERLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. 
    Source=SLSClaimantWorkbook 
    FileName=Interop.OISSERVERLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
    FusionLog=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]. 

    StackTrace: 
     at SLSClaimantWorkbook.SLSClaimantWorkbook..ctor() 
    InnerException: 

編輯: 集綁定信息:

The operation failed. 
Bind result: hr = 0x80070002. The system cannot find the file specified. 

Assembly manager loaded from: c:\WINNT\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll 
Running under executable C:\Program Files\SLS\Claimant Workbook\SLSClaimantWorkbook.exe 
--- A detailed error log follows. 

=== Pre-bind state information === 
LOG: User = INTERNAL\C15919 
LOG: DisplayName = Interop.OISSERVERLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
(Fully-specified) 
LOG: Appbase = file:///C:/Program Files/SLS/Claimant Workbook/ 
LOG: Initial PrivatePath = NULL 
LOG: Dynamic Base = NULL 
LOG: Cache Base = NULL 
LOG: AppName = SLSClaimantWorkbook.exe 
Calling assembly : SLSClaimantWorkbook, Version=0.9.31.11788, Culture=neutral, PublicKeyToken=null. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\Program Files\SLS\Claimant Workbook\SLSClaimantWorkbook.exe.config 
LOG: Using machine configuration file from c:\WINNT\Microsoft.NET\Framework\v2.0.50727\config\machine.config. 
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
LOG: Attempting download of new URL file:///C:/Program Files/SLS/Claimant Workbook/Interop.OISSERVERLib.DLL. 
LOG: Attempting download of new URL file:///C:/Program Files/SLS/Claimant Workbook/Interop.OISSERVERLib/Interop.OISSERVERLib.DLL. 
LOG: Attempting download of new URL file:///C:/Program Files/SLS/Claimant Workbook/Interop.OISSERVERLib.EXE. 
LOG: Attempting download of new URL file:///C:/Program Files/SLS/Claimant Workbook/Interop.OISSERVERLib/Interop.OISSERVERLib.EXE. 
LOG: All probing URLs attempted and failed. 
+0

你能發佈完整的錯誤信息嗎? –

+2

您忘記部署互操作庫,必需。接下來可能的故障模式是忘記在目標機器上部署和註冊OCX文件。 –

+0

山藥,我添加了完整的錯誤文本。 –

回答

0

這個錯誤是因爲我有限的瞭解的Visual Studio處理OCX文件。當我廣告時將該文件作爲程序中的參考,程序創建了「Interop.OISSERVERLIB.dll」,程序使用該文件,而不是原始的OCX。通過瀏覽到「bin \ Debug」文件夾,我能夠將DLL添加到安裝文件,並且它現在可以正常工作!

謝謝大家指點我正確的方向!

+2

只是爲了將來找到這些,還應該參考項目參考中的Interop dll。確保'Copy Local'設置爲true以在構建/發佈/部署時輸出 – Basic

相關問題