0

我们有一个名为 HostStatusControl 的自定义控件。当我们将控件放置到窗体时,我们会收到以下错误消息。ICEIOBridge是控件引用的 CLI 库之一。如果我们删除 ICEIOBridge,错误消息将与控件引用的另一个 CLI 库一起显示

问题的原因可能是什么?

---------------------------
Microsoft Visual Studio
---------------------------
Failed to create component 'HostStatusControl'.  The error message follows:

'System.IO.FileNotFoundException: Could not load file or assembly 'ICEIOBridge, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

File name: 'ICEIOBridge, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null'

   at NeST.ICE.UI.TitlePanel.HostStatusControl..ctor()



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

'
---------------------------
OK   
---------------------------

我们尝试使用 Fusion Log 查看器,日志内容如下所示。

来自 VS 错误消息的信息

---------------------------
Microsoft Visual Studio
---------------------------
Failed to create component 'HostStatusControl'.  The error message follows:

'System.BadImageFormatException: Could not load file or assembly 'TestCLI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3045f9e53eded2d0' or one of its dependencies. An attempt was made to load a program with an incorrect format.

File name: 'TestCLI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3045f9e53eded2d0'

   at NeST.ICE.UI.TitlePanel.HostStatusControl..ctor()



Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll

Running under executable  D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe

--- A detailed error log follows. 


=== Pre-bind state information ===

LOG: User = TVM\monisha.mj

LOG: DisplayName = TestCLI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3045f9e53eded2d0
(Fully-specified)

LOG: Appbase = file:///D:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/

LOG: Initial PrivatePath = NULL

Calling assembly : (Unknown).

===

LOG: This bind starts in default load context.

LOG: Using application configur...'
---------------------------
OK   

Fusion Log1(开发)

*** Assembly Binder Log Entry  (12/5/2012 @ 1:29:11 PM) ***

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = TVM\monisha.mj
LOG: DisplayName = Microsoft.VisualStudio.Platform.AppDomainManager, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///D:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = devenv.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Download of application configuration file was attempted from file:///D:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/devenv.exe.Config.
LOG: Found application configuration file (D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.Config).
LOG: Private path hint found in configuration file: PublicAssemblies;PrivateAssemblies;CommonExtensions\Microsoft\TemplateProviders;PrivateAssemblies\DataCollectors;PrivateAssemblies\DataCollectors\x86;CommonExtensions\Microsoft\Editor;CommonExtensions\Platform\Debugger.
LOG: Using application configuration file: D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.VisualStudio.Platform.AppDomainManager, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Reusing an assembly instance that was previously loaded (C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.Platform.AppDomainManager\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Platform.AppDomainManager.dll).

Fusion Log2(Windows Forms Application1.vshost.exe)

*** Assembly Binder Log Entry  (12/5/2012 @ 1:29:33 PM) ***

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  D:\TestApplication\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\WindowsFormsApplication1.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = TVM\monisha.mj
LOG: DisplayName = Microsoft.VisualStudio.HostingProcess.Utilities, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
 (Fully-specified)
LOG: Appbase = file:///D:/TestApplication/WindowsFormsApplication1/WindowsFormsApplication1/bin/Release/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = WindowsFormsApplication1.vshost.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Download of application configuration file was attempted from file:///D:/TestApplication/WindowsFormsApplication1/WindowsFormsApplication1/bin/Release/WindowsFormsApplication1.vshost.exe.config.
LOG: Configuration file D:\TestApplication\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\WindowsFormsApplication1.vshost.exe.config does not exist.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.VisualStudio.HostingProcess.Utilities, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll.
LOG: Assembly is loaded in default load context.
4

2 回答 2

0

这看起来像 DLL 地狱,尝试删除所有引用,对构建执行清理并再次引用所有内容。

于 2012-12-03T10:13:58.283 回答
0

根据我的经验,这可能是因为两件事:

  1. 如果在现有文件上发生 FileNotFoundException,即您确定该文件存在(在文件系统或 GAC 中),则可能是因为它的版本。我的意思是当你有一个名为 A 的 dll 引用 B,而 B 本身引用 C,那么当 C 更改它的版本时,你应该针对新的 dll C 重新构建 B,然后重新构建 A。结果,我认为重新- 使用 VS2010 构建用户控件(以及所有底层依赖于您自己的 dll)可能会有所帮助。
  2. 另一种可能性是您尝试在 64 位操作系统上运行 dll,但它的一个(或多个)底层依赖 dll 仅针对 32 位操作系统编译。结果,我认为使用“ x86 ”选项而不是“ any cpu ”重新构建用户控件可能会有所帮助。
于 2012-12-07T09:57:30.983 回答