My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://www.f5todebug.wordpress.com
and update your bookmarks.

Friday, 26 October 2007

Deploying VSTO 2005 Customisations in an Enterprise Environment


A colleague of mine asked me last week to take a look at some deployment issues with VSTO 2005 customizations. I did do some searching and there is lots of information out there for all kinds of scenarios but there is some misleading stuff too. I thought it may be worthwhile to post some details about the method I used to get this working.

Note: There are many different deployment scenarios that you may come across but this is the way that I dealt with it.

  • Firstly I built a VSTO 2005 customization. This was a simple document action pane which connected to a database and retrieved some details which were used to replace some bookmarks in a word document. However for ease you could just use the following code within the ThisDocument class.

    Public Class ThisDocument

    Private Sub ThisDocument_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup

    MessageBox.Show("This customization has been deployed!", "Success")

    End Sub

    Private Sub ThisDocument_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown

    End Sub

    End Class

  • Once you have built something which works you will need to deploy it. The main consideration in our environment was that the code had to be separate to the document itself, this means that deploying updates is much easier as you only have to redistribute (to the client machines) the document and not the manifests or the compiled code.


  • I established a network share with read access to the Everyone group and Full Control to a specific admin group for this type of work.


  • In Visual Studio 2005, click on Build > Publish <ProjectName>


  • At this point you must select the UNC address to your network share, if you don't use the UNC address then the permissions will be taken from the folder itself not the share.


  • This will deploy the office document and all associated files to the specified share.


  • At this point you could deploy the office document to all your client machines. However if anyone tries to run it they will get a .Net security error. This is because by default remote code execution is NOT allowed in the .Net Framework Configuration.


  • You will need to use the caspol.exe command line application which sits in the c:\<winfolder>\Micrsoft.Net\Framework\<versionnumber>\ folder


  • I used the following to set FullTrust permissions on my network share:

    caspol.exe -machine -addgroup LocalIntranet_Zone -url <yourUNCaddress>\* FullTrust -name "VSTOCustomizations" -description "Code group granting full trust to the code required for VSTO2005 extensions to Office"

  • This should allow your VSTO code to execute from within the local office document.

I hope you find this useful. I have written it rather fast so I may revisit this if it gets a lot of negative comments. I would have found this really useful a couple of days ago.

No comments:

Post a Comment

Please leave a comment if you have found this post useful, or if there are any errors. I will do my best to assist if a posted solution does not help with your problem.