我有一个应用程序正在 Sitecore 中创建一个新项目,然后打开该项目的内容编辑器,它加载正常,但是每当我尝试打开 html 编辑器时,我都会收到“NullReferenceException”。这仅在我以这种方法启动应用程序时发生。
源代码:
[Serializable]
public class PushToCMS : Command
{
public override void Execute(CommandContext context)
{
//Context.ClientPage.Start(this, "Action_PushToCMS");
Database dbCore = Sitecore.Configuration.Factory.GetDatabase("core");
Item contentEditor = dbCore.GetItem(new ID("{7EADA46B-11E2-4EC1-8C44-BE75784FF105}"));
Database dbMaster = Sitecore.Configuration.Factory.GetDatabase("master");
DatabaseEngines engine = new DatabaseEngines(dbMaster);
Item parentItem = dbMaster.GetItem("/sitecore/content/Home/Events/Parent/");
// Load existing related item if it exists
Event evt = new Event(new Guid(HttpContext.Current.Items["id"].ToString()));
Item item = dbMaster.SelectSingleItem("/sitecore/content/Home/Events/Parent/Item");
if (item == null)
item = CreateNewEvent(engine.DataEngine, parentItem, evt);
Sitecore.Text.UrlString parameters = new Sitecore.Text.UrlString();
parameters.Add("id", item.ID.ToString());
parameters.Add("fo", item.ID.ToString());
Sitecore.Shell.Framework.Windows.RunApplication(contentEditor, contentEditor.Appearance.Icon, contentEditor.DisplayName, parameters.ToString());
}
在加载这两种方法时,我能说的唯一区别是 html 编辑器的 url,但是我不知道这是在哪里定义的或者我如何控制它。
通过正常方法启动:
http://xxxx/sitecore/shell/default.aspx?xmlcontrol=RichTextEditor&da=core&id=%7bDD4372AC-5D37-4C9E-BBFA-C4E3E2A27722%7d&ed=F27055570&vs&la=en&fld=%7b60D10DBB-7CD5-4341-A960-C7AB10347A2C%7d&so&di=0&hdl=H27055699&us=%7b83D34C8A-4CC4-4CD9-A209-600D51B26AAE%7d&mo
通过 RunApplication 启动:
http://xxxx/layouts/xmlcontrol.aspx?xmlcontrol=RichTextEditor&da=core&id=%7bDD4372AC-5D37-4C9E-BBFA-C4E3E2A27722%7d&ed=F27055196&vs&la=en&fld=%7b60D10DBB-7CD5-4341-A960-C7AB10347A2C%7d&so&di=0&hdl=H27055325&us=%7b83D34C8A-4CC4-4CD9-A209-600D51B26AAE%7d&mo
对此的任何帮助将不胜感激。