shahine.com/omar/

homepage | Send mail to the author(s) contact

yet another Microsoft blogger
Page 1 of 3 in the Programming|Office category Next Page

# 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

     

Posted Sunday, March 04, 2007    Permalink    Comments [10]  View blog reactions

 

# Tuesday, June 20, 2006

Outlook 2007 Security Changes

I almost cried with joy when I read this:

Security in Outlook 2007 takes advantage of the status of antivirus software installed on a computer. This change represents a major departure from the way the Object Model Guard worked in the past. If Outlook is able to detect that antivirus software is running with an acceptable status, Outlook disables security warnings for the user. This allows external applications that previously had to resort to Extended MAPI or third-party libraries to avoid security prompts under the appropriate conditions. This new behavior helps keep Outlook secure without overwhelming the user with excessive warning messages.

Wow, no need to use Extended MAPI, Redemption or a host of other hacks to make the annoying dialog go away :-). Sweet. Another kudo for Office 2007.

[via Ryann Gregg]

Posted Wednesday, June 21, 2006    Permalink    Comments [6]  View blog reactions

 

# Monday, June 27, 2005

Updated:

99% of the appointments on my calendar say "Updated: <original appointment name>". I don't find this particularly useful, especially when I look at my calendar on a small screen like the Treo 650, or even smaller Windows Mobile Device. Half the time I have no idea what was Updated anyway, and I just blindly accept the meeting request.

In fact, most meetings go like this:

  1. You get a Meeting Request for a meeting
  2. 2 min later you get another meeting request because the person:
    • Forgot to make it recurring
    • Could not get the conference room
    • Added some attendees
    • Moved it to a new time because person foo could not make it
  3. Some time later, due to issues with step 2 you get another appointment.

If you are lucky enough to get to Step 3, you will often find that Outlook will display a message that says "Object moved" when you try and delete, accept or do anything with the third meeting request. I have no idea why.

Anyway, to make the calendar more useful, i wrote a little command line app that will simply remove "Updated: " and "FW: " from the beginning of any appointments on your calendar.

You can download it here, or in the RSS enclosure.

Usual disclaimer applies. This works on my machine, did not do bad, and I am not responsible for what it does on your machine. You must have the Outlook .NET Programability Installed for Outlook 2003.

The code looks like this:

static void Main()
{
    string[] prefixes = new string[] {"Updated: ", "FW: "};
    try
    {
        Application application = new Application();
        MAPIFolder calendar = application.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar);

        int counter = 0;

        foreach (object o in calendar.Items)
        {
            if (o is AppointmentItem)
            {
                AppointmentItem appointmentItem = (AppointmentItem)o;

                foreach (string s in prefixes)
                {
                    if (appointmentItem.Subject.ToLower().StartsWith(s.ToLower()))
                    {
                        string currentSubject = appointmentItem.Subject;
                        string cleanSubject = currentSubject.Remove(0, s.Length);
                        appointmentItem.Subject = cleanSubject;
                        appointmentItem.Save();
                
                        Console.WriteLine("subject: {0}", currentSubject);
                        Console.WriteLine(" new subject: {0}", cleanSubject);
                
                        counter++;
                    }
                }
            }
        }
    
        Console.WriteLine("Cleaned {0} of {1} Appointments", counter, calendar.Items.Count);
        Console.WriteLine("Press any key to exit.");
        Console.ReadLine();
    }
    catch (System.Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}

Posted Tuesday, June 28, 2005    Permalink    Comments [5]  View blog reactions

CleanCalendar.zip (2.41 KB)

 

# Monday, June 06, 2005

Outlook Programming

I was really excited to see the news today that Visual Studio Tools for Office 2005 will have support for Outlook. I always wondered why they would call something Visual Studio Tools for Office but only include support for Excel and Word. Well, Eric Carter and Eric Lippert have announced news that Steve Balmer made public today.

If you have been reading this blog for a while, then you know that I had some not so fun, but highly educational, months spent with none other than the .NET Framework and Outlook 2003. I found and complained to many folks inside Microsoft about what a sorry state managed programming for Outlook was, and thankfully this announcement puts to rest some of the most difficult aspects of managed programming in Outlook. Additionally, with the recent addition of the Office 2003 Primary Interop Assemblies Redistributable, even deployment gets easier.

To recap:

  • You no longer need to use a shim
  • You get your own AppDomain (translation, you won't hose other addins)
  • You have a much simpler interface to implement
  • Debugging seems much easier
  • You get a strongly typed Application object
  • You no longer have to call ReleaseComObject
  • You no longer have to meticulously manage all your Outlook objects
  • Outlook will now cleanly shutdown!
  • I no longer need to fill my brain with COM stuff that I don't care to know about
  • Some one else gets to work around Outlook bugs :-).

This all seems to good to be true :-).

You can read more here:

Many thanks to all those involved in listening to us complain endlessley about the problems and doing something about them!

Posted Tuesday, June 07, 2005    Permalink    Comments [2]  View blog reactions

 

# Friday, April 22, 2005

Office 2003 Redistributable Primary Interop Assemblies

I can't even begin to explain how happy I am that we recently released the Office 2003 PIA download. I've known about this for a while but I had to keep my mouth shut :-). Why am I excited? Just read this and you will understand.

Not being able to install the PIAs is the single biggest deployment issue I've had with my Send to OneNote from Outlook PowerToy. I have about 10 emails in my inbox from users who could not install it and up till now I had nothing really to tell them except "sorry".

Well, I plan on releasing a new version of Send to OneNote from Outlook that includes the redistributable, as well as a few dozen bug fixes and minor features.

I really appreciate the work that the office folks did in releasing this. They listened to me yell and scream for a few months about this problem, and they fixed it. Thanks guys!

Posted Saturday, April 23, 2005    Permalink    Comments [1]  View blog reactions

 

Page 1 of 3 in the Programming|Office category Next Page