Не удалось загрузить файл или сборку (.NET, Visual Studio 2010) - PullRequest
1 голос
/ 11 октября 2011

Я получаю ошибку, которая сбивает меня с толку. У меня есть приложение .NET, которое извлекает ссылку на файл OCX, используемый для автоматизации сторонней программы. Это приложение прекрасно работает, когда я запускаю его из Visual Studio, но когда я упаковываю его в файл MSI и устанавливаю его на тестовом компьютере, он не может сказать «Не удалось загрузить файл или сборку» Interop.OISSERVERLib, ... ».

У кого-нибудь есть предложения, как мне с этим справиться?

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: 

EDIT: Информация о креплении сборки:

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.

1 Ответ

0 голосов
/ 11 октября 2011

Эта ошибка из-за моего ограниченного понимания того, как Visual Studio обрабатывает файлы OCX. Когда я добавил файл в качестве ссылки в программу, программа создала файл «Interop.OISSERVERLIB.dll», и программа использовала этот файл, а не исходный OCX. Перейдя в папку «bin \ Debug», я смог добавить DLL в установочный файл, и теперь он работает правильно!

Спасибо всем за то, что указали мне правильное направление!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...