Error loading .NET2.0/Com wrapper assembly from within Excel 2002 VBScript.

Alex van Buitenen, Nov 2009.

While using Excel 2002 VB Script to load an .Net2.0/Com wrapper I got the error:

error -2147024894 (80070002)
Could not load file or assembly <AssemblyName> or one of its dependencies.

To figure out what is going wrong while loading an Assembly, use the Assembly Binding Log Viewer (FusLogVw.exe) from the .Net Framework 2.0 Command Prompt:

.Net Framework 2 Command Prompt

Figure 1. The .Net Framework Command Prompt

FusLogVw

Figure 2. FusLogVw and its settings.

"Fus" probably stand for "Fusion".
The GAC has the codename fusion during development and this name appears in several places, such as DLL names.

After starting FusLogVw and enabling the logging in the Log Settings dialog box, startup the program that has loading problems. FusLogVw will now log the loading process. You might need to click the Refresh button.
After clicking the log entry that gave the error, you will be able to view the log:

*** Assembly Binder Log Entry (13-11-2009 @ 10:59:25) ***

The operation failed.
Bind result: hr = 0x80131107. No description available.

Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\fusion.dll
Running under executable D:\Program Files\Microsoft Office\Office10\EXCEL.EXE
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: Where-ref bind. Location = D:/Study/NetCollectionToCom/NetCollectionToCom/bin/Debug/NetCollectionToCom.dll
LOG: Appbase = D:\Program Files\Microsoft Office\Office10\
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===

LOG: Processing DEVPATH.
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:///D:/Study/NetCollectionToCom/NetCollectionToCom/bin/Debug/NetCollectionToCom.dll.
LOG: Assembly download was successful. Attempting setup of file: D:\Study\NetCollectionToCom\NetCollectionToCom\bin\Debug\NetCollectionToCom.dll
LOG: Entering run-from-source setup phase.
ERR: Error extracting manifest import from file (hr = 0x80131107).
ERR: Failed to complete setup of assembly (hr = 0x80131107). Probing terminated.

Figure 3. The Assembly Binder log.

As you can see, the .Net Framework 1.1 fusion dll was loaded, while I developed my Com wrapper in .Net 2.0!
I am using Excel 2002, which is quite old now. It seems to use the .Net 1.1 Framework by default.
To change this behaviour, add a Excel.exe.confing next to the Excel.exe file (at my computer: Program Files\Microsoft Office\Office10)

<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>

Figure 4. the Excel.exe.config file.

After placing this file, my assembly loaded without any problems!