shahine.com/omar/

homepage | Send mail to the author(s) contact

yet another Microsoft blogger

 Saturday, March 03, 2007

VSTO Add-ins and Vista

So a few days go I decided to build and deploy an add-in written using VSTO 2005 Second Edition on a Vista Machine. Needless to say this didn't work. I kept getting this error:

cid:image003.png@01C75C4B.3E984E60

"The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2869"

I emailed trusty Misha and of course he helped to solve my problem.

There are two things going on.

  1. UAC is getting in the way and Visual Studio 2005 can't build an MSI out of the box that works correctly when your installer needs elevated privileges. VSTO add-ins need elevated privileges because they have to make change to Code Access Security.
  2. Exceptions that are thrown during the install process are being obscured. Misha covers this in his post on the topic.

The fix for issue number 1 is to head over to Aaron Stebner's WebLog and follow his instructions for setting the NoImpersonate flag for your Custom Actions that set up CAS (in VSTO world this would be the SetSecurity project from the VSTO deployment article.

The fix for issue #2 is covered in Misha's post.

So, how do you make this magic all work with one single build step?

  1. Download the Windows SDK Components for Windows Installer Developers.
  2. Grab wirunsql.vbs and place it in your Setup directory.
  3. Grab CustomAction_NoImpersonate.js from Aaron's post and place it in your Setup directory.
  4. Open the project in Visual Studio 2005
  5. Press F4 to display the Properties window
  6. Click on the name of your setup/deployment project in the Solution Explorer
  7. Click on the PostBuildEvent item in the Properties window to cause a button labeled "..." to appear
  8. Click on the "..." button to display the Post-build Event Command Line dialog
  9. Add the following command line in the Post-build event command line text box: cscript.exe "$(ProjectDir)CustomAction_NoImpersonate.js" "$(BuiltOuputPath)"
    cscript.exe "$(ProjectDir)WiRunSQL.vbs" "$(BuiltOuputPath)" "INSERT INTO `Error` (`Error`, `Message`) VALUES (1001, 'Error [1]: [2]')"
  10. Build your setup project

     

 

Tuesday, September 04, 2007 10:41:43 AM (Pacific Standard Time, UTC-08:00)
Hi Omar,

thanks a lot for this post.
It is much easier if we combine both tasks in one script.
I don't know, how to upload a file - otherwise I would post my version of the script.

It's just a few changes in Arons script:

...
var record

//*******
//insert new defs:
//*******
var sql2
var view2
//*******

...
view.Close()

//*********
//insert "Insert"-operation
//*********
view2=database.OpenView(sql2);
view2.Execute();
view2.Close();
//*********

database.Commit();

Steffen
Steffen
Thursday, December 13, 2007 4:52:57 AM (Pacific Standard Time, UTC-08:00)
Hi I got this error when building my setup project.

CustomAction_NoImpersonate.js(24, 1) Microsoft JScript runtime error: Subscript out of range

The error might come from the following line
var filespec = WScript.Arguments(0);

What is the value to give here. Is that msi file path?

Please help me.

Regards,
R. Pandiarajan.
R. Pandiarajan
Friday, March 28, 2008 8:42:48 AM (Pacific Standard Time, UTC-08:00)
To get around this problem budiling an MSI using Visual studio 2005 I had to do the following steps.

1. Build my MSI with custom actions using VS 2005.
2. Download/Install the ORCA editor. (to edit MSI values)
3. Use the ORCA editor to open the MSI.
4. Navigate to the CustomAction table in the MSI.
5. Locate an action with a default value of 1025 and change it to 3137.
6. Save the MSI, close ORCA and run it.

Hope these steps work for others.
Craig Franchuk
Wednesday, April 16, 2008 4:29:48 PM (Pacific Standard Time, UTC-08:00)
I'm running VISTA 64 bits and just performed the 10 steps. I now get the messsage:
'PostBuildEvent' failed with error code '2' 'Unspecified error'

Would you have any suggestions on how to proceed from here?

Thanks

Ian
Ian Bell
Monday, June 30, 2008 12:20:15 PM (Pacific Standard Time, UTC-08:00)
I hit the same error and looked at several posts - FYI, for me - the problem was not running as admin, ut was the way i entered account details for the service - i had to use the .\ delimeter for the account name - so .\myUser instead of just myUser.
nickvh
Saturday, July 05, 2008 1:16:35 AM (Pacific Standard Time, UTC-08:00)
To Ian.
I had same error. Pay attention at "'" and "`" in the post-build event - they are different, using exactly as it written here solved the problem.
Anna
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Live Comment Preview