Unable to use Ektron Framework API from class library

醉酒当歌 提交于 2019-12-12 01:52:27

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/11315880/unable-to-use-ektron-framework-api-from-class-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!