Aracılığıyla paylaş


Code Snippet: Create a BCS Solution Package for a Declarative Solution

Applies to: SharePoint Server 2010

A declarative solution runs in Microsoft Outlook 2010. A declarative solution makes declarative use of the Business Connectivity Services rich client runtime. You create XML files (for example, BDC Model, Solution Manifest (OIR.Config), Subscription, Ribbon, and Layouts) and pass them to Business Connectivity Services during packaging time. Business Connectivity Services packages and deploys the solution in Outlook and runs it as you specify in the XML files. In such a solution, you can refer to and make use of custom External Data Parts, custom actions, task panes, and ribbons.

Business Connectivity Services provides a public object model to package a declarative solution in Outlook. The package produced is deployed on the client as an Outlook add-in ClickOnce package. The binary of the add-in is not part of the package. Instead, it is provided by Business Connectivity Services as part of the managed DLLs that are currently placed in the global assembly cache at Office setup time.

The following code example shows how to create a Business Connectivity Services solution package after you have created all the necessary XML files for an Outlook declarative solution, and uploaded them to a SharePoint document library.

Prerequisites:

  • Microsoft SharePoint Server 2010

  • Microsoft .NET Framework 3.5

Create a Signed BCS Solution Package

Uri siteUrl = new Uri("https://localhost"); 
string publishSrcTitle = "PublishSrcDocLib"; 
string publishTargetTitle = "PublishTargetDocLib"; 
string solutionName = "Example Solution Name";
string solutionID = "Example Solution ID";
string certFileName = "Example Solution Cert.pfx";
string certFilePassword = "password";
X509Certificate2 packageCert = new X509Certificate2(certFileName, certFilePassword); 
Version solutionVersion = new Version(1, 0, 0, 0);
Version officeVersion = new Version(15, 0, 0, 0);
SolutionPackage package = new SolutionPackage( officeVersion, siteUrl, publishSrcTitle, solutionName, solutionID, solutionVersion); 
string depolymentFileName = package.Generate(packageCert, publishTargetTitle);

Create an Unsigned BCS Solution Package

Uri siteUrl = new Uri("https://localhost"); 
string publishSrcTitle = "PublishSrcDocLib"; 
string publishTargetTitle = "PublishTargetDocLib"; 
string solutionName = "Example Solution Name";
string solutionID = "Example Solution ID";
Version solutionVersion = new Version(1, 0, 0, 0); 
Version officeVersion = new Version(15, 0, 0, 0);
SolutionPackage package = new SolutionPackage( officeVersion, siteUrl, publishSrcTitle, solutionName, solutionID, solutionVersion); 
string depolymentFileName = package.GenerateUnsigned(publishTargetTitle);

See Also

Reference

SolutionPackage

SolutionPackage(Uri, String, String, String, Version)

Generate(X509Certificate2, String)

GenerateUnsigned(String)

Concepts

Creating Intermediate Declarative Outlook Solutions Using Business Connectivity Services