Skip to main content

Deploy VSTO solution into SharePoint document library

Visual Studio Tools for Office (VSTO) is a powerful tool to develop office based application. By deploying the VSTO solution into SharePoint document library, it will greatly reduce the maintenance effort (No need to push all the files into client machine).

Deployment architecture
There are 3 machines involved in deployment:
1. SharePoint server: The VSTO document (dot, doc, xlt or xls, etc) is uploaded to SharePoint server (either in document library or as document template).
2. File server: This server contains all the supporting files of VSTO document (.dll and configuration files, etc).
3. Client manchine: This is the client. The only thing need to be done is create security policy to specify the location of VSTO document and assembly.

Steps to deploy VSTO solution to SharePoint document library.
1. Create a VSTO project. Let's assume the project name is Proposal. It contains a Word template file Proposal.dot file. The project compiles into an assembly called Proposal.dll. Publish the project to a network share (e.g. \\fileserver\vsto\proposal). The published content looks like this:

\\fileserver\vsto\proposal
|-- Proposal.dot
|-- Proposal.dot.application
|-- Proposal.dot_1.0.0.0 (folder)
|-- Proposal.dot
|-- Proposal.dot.application
|-- Proposal.dot.dll
|-- Proposal.dot.dll.manifest


2. Create a custom document library based on existing document library. Change the document template to Proposal.dot. Copy Proposal.dot file into doctemp\Word folder in your site definition.

3. Create a document library called vstodoc using the newly created document library template.

4. In client machine, configure security policy using caspol.exe command

%windir%\Microsoft.NET\Framework\v2.0.50727\caspol -m -ag LocalIntranet_Zone -url "\\FileServer\vsto\proposal\*" FullTrust -n "Proposal Assembly"

%windir%\Microsoft.NET\Framework\v2.0.50727\caspol -m -ag LocalIntranet_Zone -url "http://SharePointServer/vstodoc/*" FullTrust -n "VSTO Document"

5. Reset IIS. Navigate to http://SharePointServer/vstodoc/ and click New Document button on document library tool bar.

Comments

Popular posts from this blog

X509Certificate2: The system cannot find the file specified.

When I use the new X509Certificate2(fileName, password, X509KeyStorageFlags.DefaultKeySet) to create certificate from certificate file containing private key in my web application, I got following error message: System . Security . Cryptography . CryptographicException : The system cannot find the file specified . at System . Security . Cryptography . CryptographicException . ThrowCryptogaphicException ( Int32 hr ) at System . Security . Cryptography . X509Certificates . X509Utils . _LoadCertFromBlob ( Byte [] rawData , IntPtr password , UInt32 dwFlags , Boolean persistKeySet , SafeCertContextHandle & pCertCtx ) at System . Security . Cryptography . X509Certificates . X509Certificate . LoadCertificateFromBlob ( Byte [] rawData , Object password , X509KeyStorageFlags keyStorageFlags ) at System . Security . Cryptography . X509Certificates . X509Certificate2 .. ctor ( Byte [] rawData , String password , X509KeyStorageFlags keyStorageFlags ) In orde...

Forms authentication ReturnUrl strange behavior and fix

When working with .NET forms authentication, I have found a strange behavior: For example, we have a web site using form based authentication. There are only two pages in the site: login.aspx and default.aspx. Default.aspx is the protected page. Without login to the site, if you type directly the URL to the default.aspx page with ReturnUrl as QueryString like this: http://localhost/YourWebApp/Default.aspx?ReturnUrl=Default.aspx Instead of redirect you to the login.aspx page, you will directly get http unauthorized error (401.2). However, if you remove the ReturnUrl query string or change it to something else, you will get expected behavior: redirect to login.aspx page. It seems .NET has some special treatment to ReturnUrl parameter. In order to fix this, we need to intercept the 401 response before it sends to client and redirect user to login.aspx page. In global.asax page, we need to add this event handler:         protected void Applica...

Manage IIS 7 remotely using PowerShell and AppCmd

We can use  Windows PowerShell remoting features  to manage IIS 7 websites remotely.  Currently, remoting is supported on Windows Vista with Service Pack 1 or later, Windows 7, Windows Server 2008, and Windows Server 2008 Release 2.  Start Windows PowerShell as an administrator by right-clicking the Windows PowerShell shortcut and selecting Run As Administrator .  Enable PowerShell Remoting with Enable-PSRemoting -Force Starting a Remote Session using:  Enter-PSSession -ComputerName <COMPUTER> -Credential <USER> Now the PowerShell connected to the remote server. Any commands issued with work against the remote server. We can use the Appcmd.exe command line tool to manage remote server just as what we do locally. For example, to add an application pool: c:\windows\system32\inetsrv\appcmd add apppool /name:"Contoso" /managedPipelineMode:Integrated /managedRuntimeVersion:"v4.0" /enable32BitAppOnWin64:true To change application p...