Search code examples
tridiontridion-2011

Unable to get Core Service client working


I am trying to publish the component using core service, to do this, I just created a console application, and executed from the server. I am getting the below error message.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Tridion.ContentManager.CoreService.Client, Version=6.1.0.996, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b' or one of its dependencies. The system cannot find the file specified.

The below is my code, can anyone faced this issue?

static void Main(string[] args)
{

    try
    {
        string compid = "tcm:56-935";

        var client = new SessionAwareCoreServiceClient();
        var readoption = new ReadOptions();
        var component = (ComponentData)client.Read(compid, readoption);
        var ItemToPublish = new List<string>();
        ItemToPublish.Add(component.Id);
        var instruction = new PublishInstructionData();
        var pubtarget = (PublicationTargetData)client.Read(
                                               "tcm:0-21-65537", readoption);
        List<string> target = new List<string>();
        target.Add(pubtarget.Id);
        client.Publish(ItemToPublish.ToArray(), instruction, target.ToArray(), 
                       PublishPriority.Normal, readoption);
        Console.WriteLine("component published");
        Console.WriteLine(component.Title);
        Console.WriteLine(pubtarget.Title);
        Console.ReadLine();

    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
        Console.ReadLine();
    }
}

Solution

  • Looks like (based on your comment to Igor's answer) you're missing some config. Check out Frank's wiki post on the Tridion Practice site - https://code.google.com/p/tridion-practice/wiki/GetCoreServiceClientWithoutConfigFile