1. Create .NET console application
- File - New - Project
2. Add references
C:\Program Files\Tridion\bin\client\
- Tridion.ContentManager.CoreService.Client.dll
- (.NET) System.ServiceModel.dll
- (.NET) System.Runtime.Serialization.dll
3. Add namespaces
- using Tridion.ContentManager.CoreService.Client;
4. Copy CoreService configuration
- Tridion.ContentManager.CoreService.Client.dll.config
to application configuration file
- App.config (Project - Add New Item - Application Configuration File)
5. Connect the client using a specific binding
SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient("netTcp_2011");
6. Code away..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tridion.ContentManager.CoreService.Client;
namespace CoreServiceApp
{
class Program
{
static void Main(string[] args)
{
SessionAwareCoreServiceClient coreServiceClient = new SessionAwareCoreServiceClient("netTcp_2011");
Console.Write("Connected to CoreService with user " + coreServiceClient.GetCurrentUser().Title + " in session " + coreServiceClient.GetSessionId());
//code..
coreServiceClient.Close();
}
}
}
No comments:
Post a Comment