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 11:41:43 AM (Pacific Daylight Time, UTC-07: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 9:42:48 AM (Pacific Daylight Time, UTC-07: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 5:29:48 PM (Pacific Daylight Time, UTC-07: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 1:20:15 PM (Pacific Daylight Time, UTC-07: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 2:16:35 AM (Pacific Daylight Time, UTC-07: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
Wednesday, September 03, 2008 3:40:17 PM (Pacific Daylight Time, UTC-07:00)
Hello.

I have an installer that installs BOTH a windows forms application AND a windows service. I have all the custom actions setup (install, commit, rollback, uninstall) for the windows service primary output. These projects are written in Visual Studio 2003. Do these fixes not apply to Setup projects made with 2003?

I know there is no "PostBuildEvent" on VS.NET 2003 Setup projects, but I have done the steps you mentioned above by hand to the MSI (i.e. - I ran the cscript.exe commands via cmd.exe on the MSI file). I then run the installer on TWO different Vista machines, I get TWO different errors:
1. The installer will simply hang and stop responding (I'm assuming on the windows service custom actions).
2. The installer will throw the 2869 error mentioned above in the article.

I am running the installer under an administrator account and I have the UAC turned OFF.

Whats really weird is that earlier, I ran the same installer (WITHOUT the changes mentioned here) on a Vista machine that had UAC turned ON and it failed. I then turned the UAC OFF, re-ran the unmodified MSI and it then installed correctly! So weird.

Any ideas?
Chris
Wednesday, September 03, 2008 6:54:15 PM (Pacific Daylight Time, UTC-07:00)
To follow up to my post above, this fix DOES WORK for VS.NET 2003 Setup projects (except for the "PostBuildEvent" property does not exist for a "Setup" project in VS.NET 2003).

For the hanging I was getting with my installer, it turned out to be DEP (http://www.mydigitallife.info/2007/01/15/disable-and-turn-off-or-enable-or-turn-on-data-execution-prevention-dep-in-windows-vista/) was enabled and killing my installer. I disabled and rebooted and was able to apply this fix and install my app without it hanging.
Chris
Friday, September 05, 2008 6:29:07 AM (Pacific Daylight Time, UTC-07:00)
HI, I have followed the 10 steps and I'm getting the following error:

Error 1001: Object reference not set to an instance of an object.


Any ideas....

thanks
Luis
Monday, March 09, 2009 8:28:53 AM (Pacific Daylight Time, UTC-07:00)
Hello,
I implemented steps you described above.
But when I try to run msi file, it gives error:

error 1001: access to the path "some directory/app.InstallState" denied


do you have any idea?
kadir
Comments are closed.