Search code examples
c#visual-studio-2010ektron

Unable to use Ektron Framework API from class library


Using Ektron v8.02, I've created a simple class library that makes use of the Ektron.Cms.Framework.Core.Content namespace.

I've added a console app to the solution to help with testing; to the console app I added a project reference to the original class library and an App.Config file with the appropriate Ektron.DbConnection connection string pointing to our dev Ektron database.

Briefly, here is the code in question:

Console app for testing

static void Main(string[] args) {
    MyClass instance = new MyClass();
}

Class library

public class MyClass {
    private Ektron.Cms.Framework.Core.Content.Content cAPI;

    public MyClass() {
        //** exception here **
        cAPI = new Ektron.Cms.Framework.Core.Content.Content();
    }
}

An exception is thrown in the MyClass constructor when I try to create a new instance of the Content API. The exception is an IncompatibleTypesException which says:

While resolving dependencies for Ektron.Cms.IRequestInfoProvider, the provided type is not compatible with Ektron.Cms.IRequestInfoProvider.

The Ektron Dev forums have a couple of threads here and here that mention this exact problem, but no solutions have been posted. Hoping someone with experience using the Framework API from a class library will recognize this situation and offer some advice before I have to call Ektron support.


Solution

  • This wasn't available with version 8.02, but the newer versions (v8.6+ I think) have an alternate "3-tier" set of dlls. These "3-tier" dlls use WCF to communicate with the workarea/database, so they have no dependency on web stuff like HttpContext. You can find the files in the installation directory; the path will be something like: C:\Program Files (x86)\Ektron\CMS400v86\startersites\3TierMin\Content

    I've used these dlls with great success when writing console apps to do things like import or modify content. There are a few extra config files you'll need to bring along, and I think you need an AppSetting that points to the url of your "middle tier" -- the Ektron site that has your workarea.