I have an Excel addin. It depends on an Assmbly which I register in the GAC.
addinSpy gives this warning (sorry it does not format well)
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.
I specifically dont understand what "Attempting download of new URL file:///C:/Program Files (x86)/Poly/PolyAddins/PolyExcel/DBExcelAddin.dll." fails as that is exactly where it is.
So I assume Fusion is the next step to try and work out what is going on.
*** 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.
I am positive it is telling me what to do but I dont understand it so could you please let me know.
System.BadImageFormatException: Could not load file or assembly ...
It is not a warning, it an error. BadImageFormatException was the outcome. This "addinSpy" utility gives you a poor diagnostic, the file is actually found just fine. It simply cannot be loaded, the CLR threw the BadImageFormatException when it tried to load the assembly.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727
This is what caused the exception, note the version number of the .NET Framework, 2.0.50727. That's a bad version, your assembly requires the .NET 4.0 version of the framework in order to load and execute correctly. CLR v2 doesn't know how to load v4 assemblies.
This is generically the infamous CLR version injection problem. Whatever add-in gets loaded first determines what version of the CLR is loaded into the Office program. And woe-be-you if that's an old version, like v2.0.50727. Any add-in that loads afterwards and requires a later version is doomed to fail to load. BadImageFormatException is the diagnostic.
Your Fuslogvw.exe gives a pretty strong hint that it is actually your "addinSpy" utility that causes the problem. Fairly ironic, you'll need to find an update for this program, one that uses .NET v4. Or just retire it and stick with Fuslogvw.exe.
The general solution to this problem is to always force the latest version of the CLR to be loaded, even if the add-in asks for an earlier version. That requires a .config file, in your case named Excel.exe.config and copied into the same directory where Excel.exe lives. It needs to look like this:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
User contributions licensed under CC BY-SA 3.0