5

Hi i have upgraded my project from tridion 2011 sp1 dd4t 1.24 to tridion 2013sp1 dd4t 1.3. after upgrade my code is working fine with static pages and reed component presentation but it throws null when try to read dynamic component using below code

  public ViewResult Component(int publicationId, int componentId, string viewName)
        {
            TcmUri tcmUri = new TcmUri(publicationId, componentId, 16, 0);
            IComponent component;
            //IComponent c = ComponentFactory.GetComponent("tcm:71-23455-16", "tcm:71-23868-32");
            if (ComponentFactory.TryGetComponent(tcmUri.ToString(), out component))
            {
                return View(viewName, component);
            }
            // optionally throw exception in case component is not found
            return null;
        }

i have checked CT and component is published successfully in broker.

i have also tried getCompontnt mehtod

IComponent c = ComponentFactory.GetComponent(tcmUri.ToString(), tcmUrict.ToString());

but gives error

[ComponentNotFoundException: Error in the application.]

DD4T.Factories.ComponentFactory.GetComponent(String componentUri, String templateUri) +379 Tourism.Web.Mvc.Controllers.ComponentController.Component(Int32 publicationId, Int32 componentId, String viewName) in c:\Websites\TourismNewFinal\Tourism.Web.Mvc\Controllers\ComponentController.cs:52 lambda_method(Closure , ControllerBase , Object[] ) +369 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +261 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +39 System.Web.Mvc.Async.<>c__DisplayClass42.b__41() +34 System.Web.Mvc.Async.<>c__DisplayClass39.b__33() +124 System.Web.Mvc.Async.<>c__DisplayClass4f.b__49() +837307 System.Web.Mvc.Async.<>c__DisplayClass37.b__36(IAsyncResult asyncResult) +15 System.Web.Mvc.Async.<>c__DisplayClass2a.b__20() +33 System.Web.Mvc.Async.<>c__DisplayClass25.b__22(IAsyncResult asyncResult) +837892 System.Web.Mvc.<>c__DisplayClass1d.b__18(IAsyncResult asyncResult) +28 System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65 System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51 System.Web.Mvc.<>c__DisplayClass8.b__3(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +15 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51 System.Web.Mvc.<>c__DisplayClass4.b__3() +15 System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +41

OR when i select CT output format - HTML Fragment it gives below mentioned error

Line 51:             if (ComponentFactory.TryGetComponent(tcmUri.ToString(), out component))

Line 52: { Line 53: return View(viewName, component);

Source File: c:\Websites\TourismNewFinal\Tourism.Web.Mvc\Controllers\ComponentController.cs Line: 51

Stack Trace:

[XmlException: Data at the root level is invalid. Line 1, position 1.] System.Xml.XmlTextReaderImpl.Throw(String res, String arg) +195 System.Xml.XmlTextReaderImpl.ParseDocumentContent() +7556193 System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +176 System.Xml.XmlDocument.Load(XmlReader reader) +144 System.Xml.XmlDocument.LoadXml(String xml) +235 DD4T.Factories.ComponentFactory.GetIComponentObject(String componentStringContent) +167 DD4T.Factories.ComponentFactory.TryGetComponent(String componentUri, IComponent& component, String templateUri) +604 Tourism.Web.Mvc.Controllers.ComponentController.Component(Int32 publicationId, Int32 componentId, String viewName) in c:\Websites\TourismNewFinal\Tourism.Web.Mvc\Controllers\ComponentController.cs:51 lambda_method(Closure , ControllerBase , Object[] ) +212 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +261 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +39 System.Web.Mvc.Async.<>c__DisplayClass42.b__41() +34 System.Web.Mvc.Async.<>c__DisplayClass39.b__33() +124 System.Web.Mvc.Async.<>c__DisplayClass4f.b__49() +837307 System.Web.Mvc.Async.<>c__DisplayClass37.b__36(IAsyncResult asyncResult) +15 System.Web.Mvc.Async.<>c__DisplayClass2a.b__20() +33 System.Web.Mvc.Async.<>c__DisplayClass25.b__22(IAsyncResult asyncResult) +837892 System.Web.Mvc.<>c__DisplayClass1d.b__18(IAsyncResult asyncResult) +28 System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65 System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51 System.Web.Mvc.<>c__DisplayClass8.b__3(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +15 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51

1

You get an XmlException because the content of your DCP cannot be parsed as XML. Most likely this means your DCP is not a DD4T XML model.

I suggest to start with the database and look at the content of that DCP. I believe your CT is not a DD4T CT and such not producing the right XML for a DD4T model.

  • thanks mihai i have checked its DD4T CT with TBB'S Generate dynamic component and Publish binaries for component it seems fine. – meyank Apr 5 '16 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.