addinSpy警告DLL路径未找到.问题与我的dll或程序集在GAC
本文关键字:dll 我的 程序集 GAC 问题 DLL 警告 路径 addinSpy | 更新日期: 2023-09-27 17:51:10
我有一个Excel插件。它取决于我在GAC中注册的程序集。
addinSpy给出了这个警告(抱歉它不能很好地格式化)
Add-in DLL path is not found. System.BadImageFormatException: Could not load file or assembly 'file:///C:'Program Files (x86)'Poly'PolyAddins'PolyExcel'DBExcelAddin.dll' or one
of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'file:///C:'Program Files (x86)'Poly'PolyAddins'PolyExcel'DBExcelAddin.dll'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean
throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean
throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean
forIntrospection, StackCrawlMark& stackMark)
at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
at AddInSpy.AssemblyScanner.GetAssemblyInfo(String fileName, String hostName, Boolean isVstoAddIn)
Assembly manager loaded from: C:'Windows'Microsoft.NET'Framework'v2.0.50727'mscorwks.dll
Running under executable C:'Users'MCH02080'Downloads'AddInSpy.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = Username
LOG: Where-ref bind. Location = C:'Program Files (x86)'Poly'PolyAddins'PolyExcel'DBExcelAddin.dll
LOG: Appbase = file:///C:/Users/XXXXXXXX/Downloads/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
LOG: This is an inspection only bind.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:'Windows'Microsoft.NET'Framework'v2.0.50727'config'machine.config.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Poly/PolyAddins/PolyExcel/DBExcelAddin.dll.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.
我特别不明白什么"尝试下载新的URL文件:///C:/Program Files (x86)/Poly/PolyAddins/PolyExcel/DBExcelAddin.dll"失败,因为这正是它所在的位置。
所以我认为聚变是下一步尝试弄清楚发生了什么。
*** Assembly Binder Log Entry (21.03.2014 @ 10:07:51) ***
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 C:'Program Files (x86)'Microsoft Office'Office12'EXCEL.EXE
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = MyUserName
LOG: DisplayName = DBExcelAddin, Version=1.1.9.0, Culture=neutral, processorArchitecture=MSIL
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: DBExcelAddin, Version=1.1.9.0, Culture=neutral, processorArchitecture=MSIL | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/Poly/PolyAddins/PolyExcel/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = EXCEL.EXE
Calling assembly : (Unknown).
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:'Windows'Microsoft.NET'Framework'v4.0.30319'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 (x86)/Poly/PolyAddins/PolyExcel/DBExcelAddin.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:'Program Files (x86)'Poly'PolyAddins'PolyExcel'DBExcelAddin.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: DBExcelAddin, Version=1.1.9.0, Culture=neutral, PublicKeyToken=null
LOG: A partially-specified assembly bind succeeded from the application directory. Need to re-apply policy.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:'Windows'Microsoft.NET'Framework'v4.0.30319'config'machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
WRN: A duplicate assembly was found while copying the assembly item to the cache.
LOG: Binding succeeds. Returns assembly from C:'Users'Username'AppData'Local'assembly'dl3'AB9LQY47.X7Y'AANNZTWA.2TD'2f8e8cc8'00da0eb0_3141cf01'DBExcelAddin.dll.
LOG: Assembly is loaded in default load context.
我肯定它在告诉我该怎么做,但我不明白,所以你能让我知道吗
系统。BadImageFormatException: Could not load file or assembly…
这不是警告,而是错误。结果是BadImageFormatException。这个"addinSpy"实用程序给出了一个糟糕的诊断,实际上找到的文件很好。当CLR试图加载程序集时,抛出了BadImageFormatException。
从:C:'Windows' microt.net 'Framework'v2.0.50727加载的程序集管理器
这就是导致异常的原因,注意. net框架的版本号,2.0.50727。这是一个糟糕的版本,你的程序集需要。net 4.0版本的框架才能正确加载和执行。CLR v2不知道如何加载v4程序集。
这通常是臭名昭著的CLR版本注入问题。首先加载的外接程序决定将CLR的哪个版本加载到Office程序中。如果是旧版本,比如v2.0.50727,那你就倒霉了。任何加载后需要更新版本的外接程序都注定无法加载。BadImageFormatException是诊断。
你的Fuslogvw.exe给出了一个非常强烈的暗示,它实际上是你的"addinSpy"实用程序导致的问题。相当讽刺的是,您需要为这个程序找到一个使用。net v4的更新。或者干脆把它退役,继续使用Fuslogvw.exe。
这个问题的一般解决方案是总是强制加载CLR的最新版本,即使外接程序要求更早的版本。这需要一个。config文件,在您的情况下名为Excel.exe.config,并复制到Excel.exe所在的同一目录中。它需要看起来像这样:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>