System.BadImageFormatException with setup file.

Add-in Express™ Support Service
That's what is more important than anything else

System.BadImageFormatException with setup file.
Could not load file or assembly 'file:///c:\program files\mytoolbar\mytoolbar.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. 
nleung leung




Posts: 7
Joined: 2010-06-30
I have just upgrade my Toolbar project from Add-in Express 2008 to 2010 today. Everything works fine except that when I upgrade my toolbar program from the 2008 version to 2010 version using the msi setup file, I get the following error:


Detailed technical information follows:
---
Date and Time: 6/30/2010 7:35:19 PM
Machine Name: myPC
IP Address: fe80::cce4:db5e:efa6:da82%11
Current User: NT AUTHORITY\SYSTEM

Application Domain: adxregext.exe
Assembly Codebase: file:///C:/Program Files/mytoolbar/adxregext.exe
Assembly Full Name: adxregext, Version=5.2.262.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 5.2.262.0
Assembly Build Date: 6/30/2010 7:14:28 PM

Exception Source: mscorlib
Exception Type: System.BadImageFormatException
Exception Message: Could not load file or assembly 'file:///c:\program files\mytoolbar\mytoolbar.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Exception Target Site: _nLoad

---- Stack Trace ----
System.Reflection.Assembly._nLoad(fileName As AssemblyName, codeBase As String, assemblySecurity As Evidence, locationHint As Assembly, stackMark As StackCrawlMark&, throwOnFileNotFound As Boolean, forIntrospection As Boolean)
adxregext.exe: N 00000 (0x0) JIT
System.Reflection.Assembly.nLoad(fileName As AssemblyName, codeBase As String, assemblySecurity As Evidence, locationHint As Assembly, stackMark As StackCrawlMark&, throwOnFileNotFound As Boolean, forIntrospection As Boolean)
adxregext.exe: N 0011 (0xB) IL
System.Reflection.Assembly.InternalLoad(assemblyRef As AssemblyName, assemblySecurity As Evidence, stackMark As StackCrawlMark&, forIntrospection As Boolean)
adxregext.exe: N 0120 (0x78) IL
System.Reflection.Assembly.InternalLoadFrom(assemblyFile As String, securityEvidence As Evidence, hashValue As Byte[], hashAlgorithm As AssemblyHashAlgorithm, forIntrospection As Boolean, stackMark As StackCrawlMark&)
adxregext.exe: N 0035 (0x23) IL
System.Reflection.Assembly.LoadFrom(assemblyFile As String)
adxregext.exe: N 0000 (0x0) IL
AddinExpress.IE.Deployment.AddinDomainAdapter.RegisterForComInterop(register As Boolean, dllType As String, dllPath As String, showExceptions As Boolean)
adxregext.exe: N 0041 (0x29) IL


One thing to notice is that the setup program seems to reference adxregext.exe instead of adxregistrator.exe even though I did not have any reference of adxregext.exe in my Visual Studio 2010 project. The target framework of the project is .NET 4.0 Full.

Any help would be appreciated.

Thanks!
Posted 30 Jun, 2010 21:57:40 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Hi nleung.

You need to use adxregistrator to register the add-on.
Please read the following article:
http://www.add-in-express.com/creating-addins-blog/2010/04/08/office2010-32bit-64bit-single-setup/
Posted 01 Jul, 2010 06:02:48 Top
nleung leung




Posts: 7
Joined: 2010-06-30
Sergey,
Thanks for the reply. When you say I need to use adxregistrator to register the add-on, I think you mean Step 3 from this page, http://www.add-in-express.com/creating-addins-blog/2010/04/08/office2010-32bit-64bit-single-setup/. However, this has already been done and it does not work.

I think the problem is that the old version toolbar, built with ADX 2008, was installed by adxregext.exe. So when I install the new version toolbar, built with ADX 2010, it tries to uninstall the old version toolbar using adxregext.exe, even though the setup file of the new version tool uses adxregistrator.exe.

Does that make sense to you?

Thanks!
Posted 01 Jul, 2010 16:03:56 Top
nleung leung




Posts: 7
Joined: 2010-06-30
Never mind. I have found out what the problem is.
Thanks!
Posted 01 Jul, 2010 21:24:39 Top
Andrei Smolin


Add-in Express team


Posts: 14677
Joined: 2006-05-11
Hi nleung,

nleung leung wrote:
I have found out what the problem is.


May I ask you to tell me what was the cause of it?

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 02 Jul, 2010 04:31:01 Top
nleung leung




Posts: 7
Joined: 2010-06-30
Andrei,

The problem was in the RemoveExistingProducts Action of the InstallExecutSequence table of the msi file. Somehow Microsoft set the sequence value to a very late value (6550). Changing the value to 1450 will solve the problem.

I have also done some testing on this issue. It appears to only happen on upgrading an old toolbar built with ADX 2008 to a new toolbar built with ADX 2010. It is not necessary to modify the value if you are upgrading toolbar that is built with the same version of ADX, or at least using the same version of adxregext.exe/adxregistrator.exe.

Thanks!
Posted 07 Jul, 2010 21:02:28 Top
Andrei Smolin


Add-in Express team


Posts: 14677
Joined: 2006-05-11
Hi nleung,

Thank you very much for sharing this info with forum readers.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Jul, 2010 10:34:04 Top