views:

12

answers:

1

Hold your guns! I did check to see if all the project outputs are set to the same processor architecture (in this case, x64). They are. So what am I trying to do?

  1. Wrote a plugin for Autodesk Revit Architecture 2011 x64
    • targets .NET 3.5
    • x64
  2. Created a setup project
  3. Created a custom action (RegisterRevit2011Addin) for registering plugin with Revit using a supplied DLL (RevitAddInUtility.dll)
    • targets .NET 3.5
    • x64
  4. added custom action to setup project, build, install

This is the error message I get:

Error 1001. Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'RegisterRevit2011, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Just to be sure, I created a simple console test application:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var register = new RegisterRevit2011Addin.RegisterAddinCustomAction();
            Console.WriteLine(register);
            register.Context = new System.Configuration.Install.InstallContext();
            register.Context.Parameters.Add("assemblypath",     typeof(Program).Assembly.Location);
            register.Install(new Dictionary<string, string>());
            Console.ReadLine();
        }
    }
}

I compiled this targeting x64 and .NET 3.5 - voilà, it works! So I can now assume the error lies somewhere in the setup project. I have set the target platform in the setup projects properties and also set the Launch condition to 3.5.

Interesting: When I check the resulting setup.exe with dumpbin /headers, it informs me that its a x86 process!

I'm pretty sure this all worked the day before yesterday, so I'm kinda worried I messed up my system somehow. Any ideas?

A: 

This sounds like it could be the answer: http://blogs.msdn.com/b/heaths/archive/2006/02/01/64-bit-managed-custom-actions-with-visual-studio.aspx

Basically, Visual Studio (at least in the 2005 edition) runs custom actions with a 32bit shim. Manually changing that to 64bit after building the msi could do the trick. I'm looking into that right now.

Daren Thomas