Microsoft PDC10 Live Stream

Microsoft Professional Developers Conference (PDC) has been the epicenter of Microsoft’s biggest platform announcements. Leading-edge developers and architects gather to hear about the next generation of Microsoft developer technologies – this year will be no exception. PDC isn’t only about content and sessions – it’s an opportunity for you to talk with and have your questions answered by the people who work with the technologies and who can help you plan the features and architecture to support your business goals.

 

You can register for the event using the following link.

http://www.virtualtechdays.com/pdc10/registration1.aspx

 

AGENDA: http://www.virtualtechdays.com/pdc10/agenda.aspx

 

Date: 29 October, 2010
Time: 10:00 AM – 06:30 PM IST (GMT+5:30)

 

This year, Microsoft-India would be hosting live the Keynote of PDC10 at 4 Microsoft Campuses – Bangalore, Gurgaon, Hyderabad & Mumbai. These invite-only events will be attended by 10-15 Microsoft Executives and Technology Evangelists, and 20-25 Community and Industry Influencers at each location.

Got an Invitation from Microsoft to attend the event today at 7.30 PM at Microsot IDC, Hyderabad. The schedule of that event is as follows.

Timing Agenda Presenter
07:30pm-08:00pm Onsite Registration
08:00pm-09:00pm Networking Dinner
09:00pm-09:30pm Event Introduction & Welcome Note IDC Exec
09:30pm-11:30pm PDC10 Keynote LIVE (Streamed from PDC10 – Redmond, USA) Steve Ballmer

Chief Executive Officer, Microsoft Corporation

 

Advertisements

Office 2010 Developer Roadmap

Just came across some beautiful videos on Office 2010 Development and would like to share with you.

Introducing Office 2010 – whats new in Office 2010 and its integration with SharePoint

Office 2010 Development Tools – various tools that supports development of office customization and the enhancements in them

Developing Office 2010 Customizations – customizing UI in Office 2010, concepts needed for Office 2010 development on both the server and client

Introduction to Office 2010 Developer Roadmap Module – a brief description of this module

Another noteworthy thing is Development Lab. Go through the link for more details.

Getting Started with Office 2010 Development Lab

Bootstrapper package for Office 2010 PIAs

Microsoft released Bootstrapper Package Installer for Office 2010 PIAs (Primary Interop Assemblies). This installer will add ‘Microsoft Office 2010 Primary Interop Assemblies‘ to the Prerequisites Dialog Box in Visual Studio 2008/2010. This will be useful to deploy Office PIAs with the addin when deployed with ClickOnce or Setup Project.

You can download the Bootstrapper Installer from the following link.

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5d57c998-b630-4f38-afaa-b79747a3da06&displaylang=en

Creating and Handling CommandBars in multiple Inspectors of Outlook

The window which displays a single item (email/appointment/task) in the Outlook is called as an Inspector in Outlook. It is derived from the namespace Microsoft.Office.Outlook.Inspector. Inspector class has methods  and properties using which we can do modifications to the window and handle the events that are raised.

We can get Inspector object by using one approach from the following –

  • Use the Inspectors property of the Microsoft.Office.Tools.Outlook.Application class to access all of the Inspector objects in Outlook.

(or)

  • Use the GetInspector method of a specific item, such as a Microsoft.Office.Interop.Outlook.MailItem or Microsoft.Office.Interop.Outlook.AppointmentItem, to retrieve the Inspector associated with it.

(or)

  • Use the ActiveInspector method of the Microsoft.Office.Tools.Outlook.Application class to get the Inspector that currently has focus.

Now, lets see how to create a CommandBar with some buttons and handling the events of them.

Following code has been written by Sue Mosher

ThisApplication.vb  (standard module generated for VSTO 2005 Outook add-in project)

Public Class ThisApplication

Dim WithEvents allInsp As Outlook.Inspectors
Public allInspHelper As New InspectorHelperClass

Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
      allInsp = Globals.ThisApplication.Inspectors
End Sub

Private Sub ThisApplication_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
      allInspHelper = Nothing
      allInsp = Nothing
End Sub

Private Sub allInsp_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles allInsp.NewInspector
      Dim itm As Object
      Dim id As String
      On Error Resume Next

      ' for the item types you want to have your CommandBar or button
      ' add the Inspector to the wrapper class collection 
      itm = Inspector.CurrentItem
      If TypeOf itm Is Outlook.MailItem Then
            id = allInspHelper.AddInsp(Inspector)
      ElseIf TypeOf itm Is Outlook.ContactItem Then
            id = allInspHelper.AddInsp(Inspector)
      End If
      itm = Nothing
End Sub

End Class

InspectorHelperClass.vb

Imports Microsoft.Office.Interop.Outlook

Public Class InspectorHelperClass

 Public Shared InspectorsList As New InspectorWrapperCollection
 Private intID As Integer

 Public Function AddInsp(ByVal Inspector As Outlook.Inspector) As String
 Dim iWrap As New InspectorWrapper()
 Dim itm As Object
 Dim id As String

 On Error Resume Next

 'set the Inspector in the class
 iWrap.Inspector = Inspector

 'test which Outlook item type is here
 itm = Inspector.CurrentItem
 If TypeOf itm Is Outlook.MailItem Then
 iWrap.MailItem = itm
 ElseIf TypeOf itm Is Outlook.ContactItem Then
 iWrap.ContactItem = itm
 End If
 itm = Nothing

 iWrap.Key = intID
 id = CStr(intID)
 'add the class to the collection with a
 ' unique Key value.
 InspectorsList.Add(iWrap, id)

 'create buttons and menus for the Inspector
 iWrap.InitButton()

 AddInsp = id

 intID = intID + 1

 iWrap = Nothing
 itm = Nothing
 End Function

 Public Sub KillInsp(ByVal intID As Integer, ByVal inspWrap As InspectorWrapper)
 Dim inspWrap2 As InspectorWrapper

 On Error Resume Next

 inspWrap2 = InspectorsList.Item(CStr(intID))
 ' check to make sure we're removing the
 ' correct Inspector from the collection.
 If Not inspWrap2 Is inspWrap Then
 Err.Raise(1, Description:="Unexpected Error in KillInsp")
 Else
 InspectorsList.Remove(CStr(intID))
 End If

 inspWrap2 = Nothing
 End Sub
End Class

InspectorWrapper.vb (This code is developed by Ken Slovak)

Imports Microsoft.Office.Core
Imports Word = Microsoft.Office.Interop.Word
Imports Microsoft.Office.Interop.Outlook

Public Class InspectorWrapperCollection
 Inherits DictionaryBase

 Public Overloads Sub Add(ByVal myWrap As InspectorWrapper, ByVal myKey As String)
 MyBase.Dictionary.Add(myKey, myWrap)
 End Sub

 Default Public Property item(ByVal theKey As String) As InspectorWrapper
 Get
 Return CType(MyBase.Dictionary.Item(theKey), InspectorWrapper)
 End Get
 Set(ByVal value As InspectorWrapper)
 MyBase.Dictionary(theKey) = value
 End Set
 End Property

 Public ReadOnly Property keys() As ICollection
 Get
 Return MyBase.Dictionary.Values
 End Get
 End Property

 Public Sub Remove(ByVal theKey As String)
 MyBase.Dictionary.Remove(theKey)
 End Sub
End Class


Public Class InspectorWrapper
 Private WithEvents _thisInsp As Outlook.Inspector
 Private WithEvents _thisMail As Outlook.MailItem
 Private WithEvents _thisContact As Outlook.ContactItem
 Private WithEvents _cbb As Office.CommandBarButton

 Private _obj As Object
 Private _intID As Integer
 Private _tag As String
 Private _hasMailInspector As Boolean
 Private _hasWordEditor As Boolean

 Private Sub _cbb_Click1(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) _
 Handles _cbb.Click
 Dim msgText As String

 On Error Resume Next
 'code here to handle a click of the menu/toolbar button
 ' and perform whatever function you want.
 msgText = "You clicked the button on the " & _
 _thisInsp.Caption & " window."
 MessageBox.Show(msgText, "Command Button Click Event")
 End Sub

 Public Sub New()
 On Error Resume Next

 _thisInsp = Nothing
 _thisMail = Nothing
 _thisContact = Nothing
 _cbb = Nothing
 _obj = Nothing

 _hasWordEditor = False
 End Sub

 Protected Overrides Sub Finalize()
 On Error Resume Next

 _thisInsp = Nothing
 _thisMail = Nothing
 _thisContact = Nothing
 _cbb = Nothing
 _obj = Nothing
 End Sub

 Public Function InitButton() As Boolean
 On Error Resume Next

 'if you want buttons only for
 ' certain item types you can test
 ' for that here using
 ' _thisInsp.CurrentItem.Class or TypeOf _thisInsp.CurrentItem
 Call CreateButtons(_thisInsp)

 'you can now enable/disable buttons depending
 ' on what type if item is opened if you want.

 End Function


#Region "InspectorWrapper class properties"
 Public WriteOnly Property MailItem() As Outlook.MailItem
 Set(ByVal value As Outlook.MailItem)
 _thisMail = value
 _hasMailInspector = True
 End Set
 End Property

 Public WriteOnly Property ContactItem() As Outlook.ContactItem
 Set(ByVal value As Outlook.ContactItem)
 _thisContact = value
 _hasMailInspector = False
 End Set
 End Property

 Public Property Inspector() As Outlook.Inspector
 Get
 Inspector = _thisInsp
 End Get
 Set(ByVal value As Outlook.Inspector)
 _thisInsp = value
 End Set
 End Property

 Public Property Key() As Long
 ' key is used to set unique tag for each CommandBarButton
 Get
 Key = _intID
 End Get
 Set(ByVal value As Long)
 _intID = value
 End Set
 End Property
#End Region

#Region "Open and Close event handlers for Outlook object properties"

 Private Sub _thisInsp_Close() Handles _thisInsp.Close
 On Error Resume Next

 Me.KillButtons()

 Globals.ThisApplication.allInspHelper.KillInsp(_intID, Me)
 _thisInsp = Nothing
 End Sub

 Private Sub _thisContact_Close(ByRef Cancel As Boolean) Handles _thisContact.Close
 On Error Resume Next

 'can handle various events for the contact item
 ' in the Inspector like Close and Open.

 If Cancel = False Then
 Me.KillButtons()
 Globals.ThisApplication.allInspHelper.KillInsp(_intID, Me)
 _thisInsp = Nothing
 End If
 End Sub

 Private Sub _thisContact_Open(ByRef Cancel As Boolean) Handles _thisContact.Open
 On Error Resume Next

 'can handle various events for the contact item
 ' in the Inspector like Close and Open.
 End Sub

 Private Sub _thisMail_Open(ByRef Cancel As Boolean) Handles _thisMail.Open
 On Error Resume Next

 'can handle various events for the mail item
 ' in the Inspector like Close and Open.
 End Sub

 Private Sub _thisMail_Close(ByRef Cancel As Boolean) Handles _thisMail.Close
 On Error Resume Next

 'can handle various events for the mail item
 ' in the Inspector like Close and Open.

 If Cancel = False Then
 Me.KillButtons()
 Globals.ThisApplication.allInspHelper.KillInsp(_intID, Me)
 _thisInsp = Nothing
 End If
 End Sub

#End Region

#Region "Private procedures to create and remove toolbars,menus, and buttons in the wrapped Inspector"

 Private Sub CreateButtons(ByVal myInsp As Outlook.Inspector)
 On Error Resume Next

 'Adding a new menu item and a button to the main menu for any Inspector
 ' must take a different approach if using Word as email editor.
 If (myInsp.IsWordMail = True) And _
 (myInsp.EditorType = Outlook.OlEditorType.olEditorWord) Then

 _hasWordEditor = True
 _obj = Nothing

 ' #### ADD CODE HERE TO ADD TOOLBAR TO WORD

 Else
 _hasWordEditor = False
 _obj = myInsp

 Me.CreateToolbar()
 End If

 Err.Clear()
 End Sub

 Private Sub CreateToolbar()
 'add a toolbar to the main Inspector  bar
 ' in the Inspector.
 Dim _tag As String
 Dim myToolBar As Office.CommandBar

 On Error Resume Next

 _tag = "This string is unique to this button" & CStr(_intID)

 'check for the toolbar existing already and do not create
 ' it if does exist. The checking code would set a
 ' Boolean variable named blnToolbarExists.

 myToolBar = _thisInsp.CommandBars("My Bar")
 If myToolBar Is Nothing Then
 myToolBar = _thisInsp.CommandBars.Add(Name:="My Bar", Temporary:=True)
 End If

 ' add the button to the toolbar 
 _cbb = myToolBar.Controls.Add(Type:=Office.MsoControlType.msoControlButton, _
 Temporary:=True)
 With _cbb
 .Tag = _tag
 .Caption = "Test Button"
 .TooltipText = "The ToolTip for the button"
 End With

 myToolBar.Visible = True
 myToolBar = Nothing
 End Sub

 Private Sub KillButtons()
 Dim oControl As Office.CommandBarControl

 On Error Resume Next
 ' if you had multiple buttons, you'd need a different tag
 ' property for each one and would delete each one individually
 oControl = _obj.CommandBars.FindControl(Tag:=_tag)
 If Not oControl Is Nothing Then
 oControl.Delete()
 End If

 oControl = Nothing
 End Sub
#End Region
End Class

Code has been adapted from the following sites. You can find more information regarding this there. Keeping it here so that it helps someone who is in need of it.

  1. http://www.outlookcode.com/codedetail.aspx?id=1344
  2. http://www.slovaktech.com/code_samples.htm#InspectorWrapper
  3. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnhcvb04/html/vb04c10.asp

Error: WriteFile failed => 0x5(5) when Makecert is run

Problem:

Makecert -sv MyCert.pvk -n”CN=MyCompanyCert” MyCert.cer -b01/01/2009 -e 12/31/2018

While executing the above command, sometimes we get the following error.

Error: WrtieFile failed => 0x5<5>

Solution:

The solution for this is to run the command prompt in admin mode.

This can be done by right-clicking on the cmd and selecting ‘Run as Administrator‘.

Hope this helps!

Check for appplication updates programmatically using ClickOnce Deployment

By default, ClickOnce provides two ways to update the application after installed in the client.

  1. Check everytime when the customization runs
  2. Check at regular intevals
ClickOnce Deployment Update Options

Default update types in ClickOnce Deployment

With the above, the user has to wait till it completes checking for the updates every time when the customization is loaded or at some time interval. It will be a waste of time for the users if application does not  update builds frequently.

How it would be if we provide a button for checking for updates when the user wish to do?

Hmm… Do you think that this is a headache process and hard to implement?

But, NO!

Here are the quick and simple steps to do this.

  1. Create a Windows Forms Application
  2. Place a button and call the following code. (It will check for updates and install them for you when the button is clicked)
Private Sub InstallUpdateSyncWithInfo()
    Dim info As UpdateCheckInfo = Nothing

    If (ApplicationDeployment.IsNetworkDeployed) Then
        Dim AD As ApplicationDeployment = ApplicationDeployment.CurrentDeployment

        Try
            info = AD.CheckForDetailedUpdate()
        Catch dde As DeploymentDownloadException
            MessageBox.Show("The new version of the application cannot be downloaded at this time. " + _
                                       ControlChars.Lf & ControlChars.Lf & "Please check your network" + _
                                       "connection, or try again later. Error: " + dde.Message)
            Return
        Catch ioe As InvalidOperationException
            MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application." + _
                                      "Error: " & ioe.Message)
            Return
        End Try

        If (info.UpdateAvailable) Then
            Dim doUpdate As Boolean = True

            If (Not info.IsUpdateRequired) Then
                Dim dr As DialogResult = MessageBox.Show("An update is available. Would you like to " + _ 
                                                 "update the application now?", "Update Available", 
                                                 MessageBoxButtons.OKCancel)
                If (Not System.Windows.Forms.DialogResult.OK = dr) Then
                    doUpdate = False
                End If
            Else
                ' Display a message that the app MUST reboot. Display the minimum required version.
                MessageBox.Show("This application has detected a mandatory update from your current " & _
                    "version to version " & info.MinimumRequiredVersion.ToString() & _
                    ". The application will now install the update and restart.", _
                    "Update Available", MessageBoxButtons.OK, _
                    MessageBoxIcon.Information)
            End If

            If (doUpdate) Then
                Try
                    AD.Update()
                    MessageBox.Show("The application has been upgraded, and will now restart.")
                    Application.Restart()
                Catch dde As DeploymentDownloadException
                    MessageBox.Show("Cannot install the latest version of the application. " & ControlChars.Lf 
                                              & ControlChars.Lf & "Please check your network connection," + _ 
                                               " or try again later.")
                    Return
                End Try
            End If
        End If
        End If
End Sub

Now say, Ain’t this cool? 🙂

Reference: http://msdn.microsoft.com/en-us/library/ms404263.aspx

Hope this helps!

Exclusive category for VSTO in MSDN Forums

Yay! Happy to know that MSDN Forums now have an exclusive category for Office Development. Might be late yet useful. So, posting it here.

A snap from 'Office For Developers' in MSDN Forums

Microsoft Office for Developers – http://social.msdn.microsoft.com/Forums/en-US/category/officedev

It has separate wing for Outlook, Excel, Word and Access.

In addition to these, there are two other wings.