Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 920121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:39:29+00:00 2026-05-15T18:39:29+00:00

When building a Visual Studio 2010 Setup project with a CustomAction on x64 systems,

  • 0

When building a Visual Studio 2010 Setup project with a CustomAction on x64 systems, Visual Studio includes the wrong version of InstallUtilLib.dll: It installs the 32bit shim, which will not work for CustomActions compiled as 64-bit (a requirement in my case, since it depends on 64-bit native dlls).

Installing such a .msi results in the System.BadImageFormat exception.

According to this post (64-bit Managed Custom Actions with Visual Studio), the solution is to open the resulting .msi in orca.exe and replace the binary "InstallUtil".

I’d like to automate this. Any ideas?

EDIT: based on the answer provided by mohlsen, I added following script to the solution (not the setup project itself, as files added to the setup project go into the msi…):

Option Explicit
rem -----------------------------------------------------------
rem Setup_PostBuildEvent_x64.vbs
rem 
rem Patch an msi with the 64bit version of InstallUtilLib.dll 
rem to allow x64 built managed CustomActions.
rem -----------------------------------------------------------    

Const msiOpenDatabaseModeTransact = 1
Const msiViewModifyAssign         = 3

rem path to the 64bit version of InstallUtilLib.dll
Const INSTALL_UTIL_LIB_PATH = "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtilLib.dll"

Dim installer : Set installer = Wscript.CreateObject("WindowsInstaller.Installer")

Dim sqlQuery : sqlQuery = "SELECT `Name`, `Data` FROM Binary"

Dim database
Set database = installer.OpenDatabase(Wscript.Arguments(0), msiOpenDatabaseModeTransact)
Dim view : Set view = database.OpenView(sqlQuery)

Dim record : Set record = installer.CreateRecord(2)
record.StringData(1) = "InstallUtil"
view.Execute record

record.SetStream 2, INSTALL_UTIL_LIB_PATH

view.Modify msiViewModifyAssign, record
database.Commit

Set view = Nothing
Set database = Nothing

Next, I edited the Setup projects properties: I set the PostBuildEvent property to:

wscript.exe "$(ProjectDir)\..\Setup_PostBuildEvent_x64.vbs" $(BuiltOuputPath)

Note: Right-clicking the setup project in solution explorer and then selecting "Properties" opens up the wrong dialog ("Property Pages"). You want the "Properties Window" (CTRL+W, P).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:39:30+00:00Added an answer on May 15, 2026 at 6:39 pm

    Not sure how you want to automate this, through script, code, etc. But in any case, this functionality is all available through the Windows Installer SDK, which I believe is part of the Windows SDK now (used to be the Platform SDK).

    Regardless, here is a VBScript I have used in the past to manually add a file to an MSI. It has been a while, but I just ran it on a MSI to test, and verified with Orca and the assembly was added to the binary table. This should point you in the right direction.

    Option Explicit
    
    Const msiOpenDatabaseModeTransact     = 1
    Const msiViewModifyAssign         = 3
    
    Dim installer : Set installer = Nothing
    Set installer = Wscript.CreateObject("WindowsInstaller.Installer")
    
    Dim sqlQuery : sqlQuery = "SELECT `Name`,`Data` FROM Binary"
    
    Dim database : Set database = installer.OpenDatabase("YourInstallerFile.msi", msiOpenDatabaseModeTransact)
    Dim view     : Set view = database.OpenView(sqlQuery)
    Dim record
    
    Set record = installer.CreateRecord(2)
    record.StringData(1) = "InstallUtil"
    view.Execute record
    
    record.SetStream 2, "InstallUtilLib.dll"
    
    view.Modify msiViewModifyAssign, record 
    database.Commit 
    Set view = Nothing
    Set database = Nothing
    

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 488k
  • Answers 488k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I needed to use Areas. See: http://elegantcode.com/2010/03/13/asp-net-mvc-2-areas/ I created a… May 16, 2026 at 8:36 am
  • Editorial Team
    Editorial Team added an answer <select name="menu1" id="menu1"> <option value="1"<?php selected(get_option('menu1'),1); ?>>Microsoft</option> <option value="2"<?php selected(get_option('menu1'),2);… May 16, 2026 at 8:36 am
  • Editorial Team
    Editorial Team added an answer aside from a wiki (which has thus far failed to… May 16, 2026 at 8:36 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm building an ASP.NET MVC 2 site with Visual Studio 2010 Beta 2. Out
In Visual Studio 2010, I have project A (asp.net application). Project A references project
I've recently upgraded my project to Visual Studio 2010 from Visual Studio 2008. In
I've recently upgraded my project from Visual Studio 2008 to Visual Studio 2010. By
I have issues to build a project using external libraries with Visual Studio 2010
I have create a LINQ-to-SQL project in Visual Studio 2010 using Dynamic Data. In
I need to get VS 2010 projects that are using Visual Studio Tests building
I have around 50 projects in Visual Studio 2005 that I am building a
Aside from faster development time (Visual Studio 2010 beta 2 has no T4 templates
For a solo developer using Visual Studio 2010 beta 2 is TFS Basic a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.