Unable to use Ektron Framework API from class libr

2019-08-16 00:41发布

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.

3条回答
戒情不戒烟
2楼-- · 2019-08-16 00:53

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.

查看更多
对你真心纯属浪费
3楼-- · 2019-08-16 01:00

I think you're going to give yourself a lot of long coding hours and reference/gac nightmares trying to reference web libraries from a console app. I'm sure it can be done and I've had limited success with it myself. But when trying to call Ektron API's from a console app, I highly recommend creating some web services hosted in your ektron app that would do the heavy lifting with the API and then having your console app call the webservices. By doing this you can start threading requests and doing all sorts of automation processes.

Also when you upgrade (8.6 has a cool new editor) this will not cause any dependency issues and need to be recompiled. Their webservices are backwards compatible.

No code.. but hope this helps, let me know if I can clarify.

查看更多
【Aperson】
4楼-- · 2019-08-16 01:02

It is not that difficult. I had created a class similar to what you are talking about. My goal was actually to use this class library to import the content that I have from out in-house CMS.

But instead of using Ektron.Cms.Framework.Core.Content.Content() I was using Ektron.Cms.API.Content.Content().

May be you can give that a try.

查看更多
登录 后发表回答